IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
A more complicated example
editA more complicated example
editLet’s construct a slightly more complicated example: a boolean query that contains both a filter and a query. This is a very common activity in elasticsearch queries, so it will be a good demonstration.
The curl version of the query:
curl -XGET 'localhost:9200/my_index/my_type/_search' -d '{ "query" : { "bool" : { "filter" : { "term" : { "my_field" : "abc" } }, "should" : { "match" : { "my_other_field" : "xyz" } } } } }'
And in PHP:
$params = [ 'index' => 'my_index', 'type' => 'my_type', 'body' => [ 'query' => [ 'bool' => [ 'filter' => [ 'term' => [ 'my_field' => 'abc' ] ], 'should' => [ 'match' => [ 'my_other_field' => 'xyz' ] ] ] ] ] ]; $results = $client->search($params);