Search code examples
elasticsearchkibanaelastic-stack

while doing "query": { "match_all" : {} } i get less number of records than the total in elasticsearch


There are in total 1000000 records, but when i execute the below query it shows only 10,000

GET /Index_Here/_search
{
  
  "query": { "match_all" : {} }
}

I have added the below size also still it does not work

GET /Index_Here/_search
{
  "from" : 0, "size" : 20000,
  "query": { "match_all" : {} }
}

even i have updated the max windows size also

PUT /Index_Here/_settings
{
  "index": {
    "max_result_window": 200000
  }
}

Solution

  • Tldr;

    This is a default in elasticsearch, to offer a good trade of between performance and accuracy.

    Solution

    You may disregard this "optimisation" by using the param track_total_hit.

    GET /Index_Here/_search
    {
      "track_total_hits": true,
      "query": { "match_all" : {} }
    }