Hi App Search Team,
I have a use case where I would like to show facets with a count against all the documents in an index at the initial app load.
The challenge is that my index can be large and the query can timeout as it tries to compute the facet values and their count values against all documents.
To overcome this challenge, I thought about caching my default facets that show approximate count values so that the facets can be loaded fast at the initial app load and let users refine their searches. (Displaying a default search results at the page load would be nice too, but that is optional)
I have reviewed the App Search documentation, but I didn't find any guidance on it so I wanted to ask the team here to see if there are any ways to achieve this.
So far, the 2 options that I have thought of so far are:
Option 1 - Introduce a constant helper field
For every documents in the index, introduce a constant helper and configure the App Search to include this field in the global filter. This will force the query to have a filter context that can in turn make Elasticsearch cache the query results. To warm up the cache, my server will issue the same query periodically or whenever changes are introduced to the index.
Option 2 - Build a custom server-side facet component
Build a custom facet component that fetches facet values server-side and retrieve values from my own system's cache or from Elasticsearch's Aggregation query that can be cached on Elasticsearch according to the official documentation.
Does any of these options make sense? Is there any other option that your team would recommend?
Thanks in advance for looking into this question and I am looking forward to hear your response!