0

When we delete an item form the cache and then immediate do a search the search does not reflect the recent deletion.  

The search happens immediately after the index deletion or update.

How can I fix this? I don't see an aws configuration setting that will ensure the index is updated fully before returning.

M Akin
  • 446
  • 6
  • 18
  • 1
    How many shards does your OpenSearch cluster have? Have you tried setting [wait_for_active_shards](https://opensearch.org/docs/2.4/api-reference/document-apis/delete-document/) to `'all'`? – cam Feb 14 '23 at 20:13
  • Thanks, I finally figured out the syntax for that in the dotnet client, but it times out waiting. I added the wait on the dashboard, and I get the following error now: "type" : "unavailable_shards_exception", "reason" : "[invoices][2] Not enough active copies to meet shard count of [ALL] (have 1, needed 2). Timeout: [1m], request: [BulkShardRequest [[invoices][2]] containing [delete {[invoices][306]}]]" – M Akin Feb 14 '23 at 22:58
  • I fixed that by adding more to my server with more data nodes, however, the wait_for_active_shards = 'all' still does not return a search without that record (but it is gone if you query again in a second or two. Any other ideas @cam – M Akin Feb 15 '23 at 22:40
  • 1
    Actually, I got it fixed by adding ?refresh=wait_for to the query string. This article was helpful. https://stackoverflow.com/a/40678914/98802 – M Akin Feb 15 '23 at 23:27

1 Answers1

1

I was able to get it fixed by adding the "?refresh=wait_for" on the query string.

like DELETE /invoices/306?refresh=wait_for

This is a link to the ElasticSearch version of this problem here is a link to the OpenSearch docs. Pay attention to the refresh paramater. and

M Akin
  • 446
  • 6
  • 18