Delay of Atlas search index update when documents are updated

Greetings,

We encounter cases where running an Atlas search query after an update of documents don’t reflect the changes.
For example if I have document:

{_id: x, bool_field: true}

And I update it to:

{_id: x, bool_field: false}

I get a successful response from Mongo that document was updated.
When I perform search query with bool_field equals to false this document is not included.

After looking on documentation here, I assume the reason is that the Atlas index wasn’t updated - the question is whether we can get a successful response from Mongo only after the Atlas index was updated? (or any other method I can guarantee the index update)

If you make changes to the collection for which you defined Atlas Search indexes, the latest data might not be available immediately for queries. However, mongot monitors the change streams, which allows it to update stored copies of data, and Atlas Search indexes are eventually consistent.

Thanks,
Ofer

Hi @Ofer_Chacham,

The team would like to help but we need a bit more information. Can you share your index definition and your query?

Hi @Marcus, I don’t believe that a specific index and query are relevant here, I think the example is enough to understand the issue which is also documented in the documentation.
I just wonder if there is something we can do to promise Atlas index will be updated before getting a successful response from Mongo.

Thanks,
Ofer.

Well, search engines based on Lucene are eventually consistent and do not respect read concerns. It’s a trade off made in favor of other features and opportunities. So, if your question is about a read concern or a read-after-write use case, then an index is not applicable. The best thing you can do is read from the primary, but there’s no guarantee.

The other issue, and why we almost always request an index and even a query example is that if you have set dynamic: true, we do not index boolean by default today. It will change in the future, but that’s how it is today.

I’m only asking for more information to ensure I get the most accurate answer to you in the fastest time. I hope the above two points help.

1 Like

It helped, thanks Marcus.
The boolean field was only for simple demonstration - the real scenario is read after write of a string field.
Thanks!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.