Elasticsearch-php: How to elasticsearch return all hits

Created on 24 May 2018  ·  2Comments  ·  Source: elastic/elasticsearch-php

Code :
$client = ClientBuilder::create()->build(); $params = [ 'index' => 'rbmq', 'type' => 'users', 'body' => [ 'query' => [ 'match' => [ 'email' => [ 'query' =>'@gmail.com', 'operator'=>'and' ] ], ] ] ]; $results = $client->search($params); $r=$results["hits"]["hits"]; $total = $results["hits"]["total"]; echo "TOTAL: ". $total ."<br>"; foreach ($r as $key ) { echo $key["_source"]["email"],"<br>" ; echo $key["_source"]["username"]; echo "<br>"; }
Result:
TOTAL: 13
return hits: 10 hits, WHY??,

Most helpful comment

elasticsearch limits the number of records returned by any query to 10 records by default

All 2 comments

elasticsearch limits the number of records returned by any query to 10 records by default

Yep. Increase the size parameter, or use the scroll api to retrieve a very large list of hits.

@hoduckhoa Questions like this are best asked at the Elasticsearch Discuss Forums. We try to reserve tickets in this repository for bugs, feature requests and help with the Elasticsearch-PHP client itself, not general Elasticsearch questions. Thanks!

Was this page helpful?
0 / 5 - 0 ratings