Jack
Jack

Reputation: 5880

ElasticSearch Scroll only return 10 records

I used scroll to query ES, but I still got 10 records, my query as following:

curl -XGET 'http://10.0.0.5:9200/myin/app/_search?scroll=1m' -d '{
  "_source": "appAd",
  "query": {
    "bool": {
      "must_not": {
        "term": {
          "app.raw": "dt"
        }
      }
    }
   }

the following is the result:

"took":467,"_shards":{"total":24,"successful":24,"failed":0},"hits":{"total":760000} ...

But it only return 10 records although it hits 760000.

Upvotes: 1

Views: 633

Answers (1)

bbergvt
bbergvt

Reputation: 503

You will need to call the scroll API with the scroll_id returned in your query result to get next set of results. Continue to call until all results have been processed.

curl -XGET  'localhost:9200/_search/scroll'  -d'
{
    "scroll" : "1m", 
    "scroll_id" : "c2Nhbjs2OzM0NDg1ODpzRlBLc0FXNlNyNm5JWUc1" 
}
'

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html

Upvotes: 3

Related Questions