PHP code example of syqmk / think-elasticsearch

1. Go to this page and download the library: Download syqmk/think-elasticsearch library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

syqmk / think-elasticsearch example snippets


例如:

$id = "VdOa3GIBv0F8YUCs1PVZ";

$result = Esdb::esGetById($id);

例如:

$id = null;

$data = [
    "id"       =>  "VdOa3GIBv0F8YUCs1PVZ"
    "content"  =>  "test",
];

$result = Esdb::esInsert($data, $id);

例如:

$data_list = [
    [
        "id"       =>  "VdOa3GIBv0F8YUCs1PVZ",
        "content"  =>  "test",
    ],
    [
        "id"       =>  "VdOa3GIBv0F8YUCs1PVX",
        "content"  =>  "test",
    ]
];

$result = Esdb::esInsertAll($data_list);

例如:

$data = [
    "content"=>"think"
];

$id = 'VdOa3GIBv0F8YUCs1PVZ';

$result = Esdb::esUpdateById($data, $id);

例如:

$id = 'VNOa3GIBv0F8YUCs1PVZ';

$result = Esdb::esDeleteById($id);

例如:

$ids = ['gNPW3GIBv0F8YUCsbPUZ',"VdOa3GIBv0F8YUCs1PVX"];

$result = Esdb::esDeleteByIds($id);