Home > Net >  Difference size vs track_total_hits in Elasticsearch query
Difference size vs track_total_hits in Elasticsearch query

Time:11-22

size in elasticsearch query means no. of documents we want to fetch. track_total_hits is what ? Both are doing same task if we set track_total_hits 10 and size is 10 then i am getting 10 result.

CodePudding user response:

With size: 10 you're asking how many hits you want in the results.

With track_total_hits:...

  • true you're telling ES that you're interested to know how many total hits your query could return
  • false you're telling ES that you're not interested to know how many total hits your query could return

Settings track_total_hits: false is an optimization to prevent ES from having to count all hits if you're only interested in the first N results and are not interested in the total hit count.

  • Related