-1

I have a program that indexes multiple documents into OpenSearch every second. I make these documents available to query on a dashboard with a fixed set of filters. From what I've read online, OpenSearch will cache the results of queries.

When I index a new document or update an existing document, do I need to explicitly clear the index cache for the new (or updated) document to be available immediately after the index's refresh period elapses, or is the cache smart enough to know that the index has been updated?

My goal here is to prevent outdated data from being returned upon explicit requests, but I'd still like to cache it in the case that multiple users attempt to query the documents when no change has occurred.

Jacob G.
  • 28,856
  • 5
  • 62
  • 116
  • "From what I've read online", can you share the link to what you read? – Val Jun 21 '23 at 05:53
  • @Val From what I can see here, there exists a fields cache (where each field seems to be cached separately), along with a query cache and a request cache: https://opensearch.org/docs/latest/api-reference/index-apis/clear-index-cache/ – Jacob G. Jun 21 '23 at 13:47
  • Yeah, you don't need to worry about those. The main parameter to take into account to have fresh results is the `refresh_interval`. – Val Jun 21 '23 at 13:59
  • Thanks, I guess that answers my question then. I was just concerned that the caching mechanisms wouldn't be impacted by the refresh interval. – Jacob G. Jun 21 '23 at 14:11

1 Answers1

1

You don't need to worry about query cache, node cache and request cache. Those are low-level caches that will never return you stale information.

The main parameter to take into account to have fresh results is the refresh_interval. The shorter it is the more real-time your results are, but also the more load your put on your index. But usually 1s is perfectly admissible for near-real time cases like yours.

Val
  • 207,596
  • 13
  • 358
  • 360