I master Elasticsearch on a php client.

How can I find a lot of documents in ES, by id, equivalently to "WHERE id IN (1,2,3,4,9)" in SQL?

For mono geta I do this

$params = [ 'index' => 'my_index', 'type' => 'my_type', 'id' => 'my_id' ]; $response = $client->get($params); 

how to pull out a few records? Tried it, but it doesn't work.

  $params = [[ 'index' => 'my_index', 'type' => 'my_type', 'id' => 'my_id' ], [ 'index' => 'my_index', 'type' => 'my_type', 'id' => 'my_id2' ]]; $response = $client->mget($params); 

so

 $params = [ 'index' => 'my_index', 'type' => 'my_type', 'id' => array('my_id','my_id2') ]; $response = $client->mget($params); 

The PHP API has only https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_getting_documents.html

Here it is like it, only in the CURL request https://www.elastic.co/guide/en/elasticsearch/reference/1.4/docs-multi-get.html

    2 answers 2

    The API for elastikerca is one, and for php it is a client library.

    All kinds of elastikchercha requests are in the corresponding section https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-queries.html

    There is an ids query, maybe this is what you need https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-ids-query.html

        $response = $client->search( [ 'body' => [ 'query' => [ 'filtered' => [ 'query' => [ 'match_all' => [] ], 'filter' => [ 'ids' => [ 'type' => 'my_type', 'values' => ['my_id','my_id2'] ] ] ] ] ] ] );