Document under discriminator key won't be searched

Hi everyone, I am facing this weird issue and I was wondering if this was intended.

  1. I have 2 schemas.

BasePost which includes most common attributes for this type of document.(e.g. title, content…)
MarketPost which is a discriminator of “BasePost” which includes extra attributes.

  1. I have search index setup with title and content.

  2. I have post creation code with “UpdateOne” using MarketPost schema with “upsert” option.

Once I create “MarketPost” this post is not searchable until I query this post at least once. Once I query this “MarketPost”, then “MarketPost” is searchable. Let me give more verbose scenario.

  1. MarketPost with title: “PS4” is created (using web scrapper, so no actual user interaction)
  2. User search with term “PS4” but above MarketPost is not searched.
  3. User clicks on this “MarketPost”
  4. User search with term “PS4”, now this MarketPost is searched.

My theory is

Upon creating a document with “update and upsert”, document is not properly indexed.

I wonder if my theory is correct, hopefully someone here is able to answer my question.

Thank you.

Hi @D_Kim,

My interpretation may be incorrect here but this might be due to Eventual Consistency and Indexing Latency. More specifically:

Atlas Search supports eventual consistency and does not provide any stronger consistency guarantees. This means that data inserted into a MongoDB collection and indexed by Atlas Search will not be available immediately for $search queries.

How long in seconds approximately between step 1 and 2?

Regards,
Jason