Get query is showing only 10 results while searching for a particular data

I have indexed my email and trying to get the values of all senders email address.
I used

   Get exchangemails/email/_search?_source=sender

This returns

 {
  "took": 3,
"timed_out": false,
"_shards": {
  "total": 1,
  "successful": 1,
  "failed": 0
},
"hits": {
  "total": 21,
  "max_score": 1,
  "hits": [
     {
        "_index": "exchangemails",
        "_type": "email",
        "_id": "AVxyx7bddd6P8H4c9eLT",
        "_score": 1,
        "_source": {
           "sender": "abc@gmail.com"
        }
     },
.....
{
        "_index": "exchangemails",
        "_type": "email",
        "_id": "AVxyx1vZ6P8H4c9b6eJu",
        "_score": 1,
        "_source": {
           "sender": "xyz@gmail.com"
        }
     }
  ]
}
}

The hits total count is correct but it returns only 10 results

What is the issue here...

The default size parameter (number of records actually returned) is 10 - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html

If you change your query to GET exchangemails/email/_search?_source=sender&size=50 then you'll get 50 records.

/exchangemails/email/_search?_source=sender&from=50&size=50 will then get the next "page" of results.

The max supported value for size is 10,000, and while this can be changed system wide, utilizing scroll (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html) or search after (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html) are generally accepted as better solutions

2 Likes

Thank you

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.