Document indexed asynchronously

Hi everyone,
As I know that when we create a document, this document will be indexed asynchronously as mentioned here Documents API | Elastic App Search Documentation [7.15] | Elastic.
So when I create the document, it returns an id and I perform a search with id filter immediately, usually, it will return no result for this id.
However, when I get the document by id with that endpoint Documents API | Elastic App Search Documentation [7.15] | Elastic, it looks like that I can always get back the document by the newly created id. So is it correct, could I make use of it to overcome the not found result above?

Thank you.

As those docs say;

The documents are indexed asynchronously.

There will be a processing delay before they are available to your Engine.

You will need to put in a bit of a wait for your search.

Hi @warkolm , you're right, we need to wait a little bit before searching, but how about this one Documents API | Elastic App Search Documentation [7.15] | Elastic, do we need to wait?

Yes, because that page still says there's a delay.

Hi @warkolm , yeah I want to confirm because I did 2 test cases:

  • Create and search with id filter -> return no result
  • Create and get by id -> having the result.
    So I feel that we don't need to wait to call get by id.

No you don't.

This is how Elasticsearch works, Near real-time search | Elasticsearch Guide [7.15] | Elastic goes into that more.

I see. Thank you so much, @warkolm. Let me take a look at Elasticsearch for more information.

Hi @warkolm ,
After debugging and investigating, I saw that for the get by id Documents API | Elastic App Search Documentation [7.15] | Elastic, it will trigger a multiget in Elasticsearch.

GET http://elasticsearch:9200/.ent-search-engine-documents-abc/_mget"
{
  "ids":[
  "2aa83e11-ddf6-4336-81b8-bb9f72984acd"
  ]
}

And as Elasticsearch document said that: Get API | Elasticsearch Guide [7.15] | Elastic (Multi get (mget) API | Elasticsearch Guide [7.15] | Elastic the same mechanism)
So it looks like that my assumption is correct. Could you help me double-check that?

A get will always return the document, yes.

Thank you for the confirmation, @warkolm.