Search code examples
elasticsearchcachingrequest

What does size=0 mean in Elasticsearch shard request cache?


By default, the requests cache will only cache the results of search requests where size=0, so it will not cache hits, but it will cache hits.total, aggregations, and suggestions.

I do not understand the part where stated: "size=0".

What is the the size context/meaning here?

Does it mean that results cache will

  • cache only for empty results?
  • cache page 1 only (default 10 results I think)?

Solution

  • No, size param is useful if you want to fetch results different than 10, as default size is 10, so if you are using a search query for which you need to fetch lets suppose 1000 results, than you specify size param to 1000, without this you will get only top 10 search results, sorted on their score in descending order.

    size=0, in shard request cache, is that it will not cache the exact results(ie number of documents with their score) but only cache the metadata like total number of results(which is hits.total) and other things.