Does elastic-search's {"acknowledged":true} means actually all of indices are have been "created"?

When we add some new indices elastic-search and it returns "acknowledged".

I just want to know does {"acknowledged":true} means all of indices actually "have been created" or not.

If not, even though {"acknowledged":true} prompted, do the actual indices didn't have been created in shards when I'm trying to add large amount of indices which is taking some time?

Any information would be appreciated.

When you have elasticsearch answer after the create index API call, it should be ready to use.

Note that you can also just index documents without creating the index manually. Using index templates is helpful.

1 Like

Creating an index happens in multiple steps. First the master adds the new index to the cluster state, and then it allocates each shard (primaries and replicas) to nodes in the cluster. Typically it works on allocating more than one shard at once, but if it's busy then it might take some time before it gets around to the shards of this new index.

In response to the creation of an index, {"acknowledged":true} means that every node acknowledged just the first state update in the process. I'm not sure this is that useful to an end-user - as long as a majority of the master nodes acknowledged the first state update then the index now exists, and you can tell that this has happened from the 200 OK response code.

The process also waits for some of the shards to be assigned, using the wait_for_active_shards and timeout parameters, which default to waiting for up to 30 seconds for just the primaries all to be assigned. However if this times out then you don't see any difference in the response. This means that you can indeed create an index and receive a 200 OK response with {"acknowledged":true} even though the index is not fully created.

If this matters to you, you should repeatedly call GET _cluster/health/<index>?wait_for_status=yellow until this returns 200 OK, since this guarantees that all the primaries have indeed been assigned.

3 Likes

Thank you for the reply.

I have one more question.

I can see that when I'm trying to create indices which are massive documents within, then I can see even though I got {"acknowledged":true} message and I can notice that the size of node's folder is getting bigger and bigger .

Is it okay to think {"acknowledged":true} doesn't guarantees that all of 'documents' which are within indices, have been created ?

I don't really understand the question. You were asking about the create index API which creates an index containing no documents at all. The APIs that let you add documents don't say {"acknowledged":true} AFAIK.

1 Like

I have one more question.

curl -XPOST "localhost:9200/_bulk?pretty" -H "Content-Type: application/json" --data-binary @example.json

After I've sent a query something like this, which is creates tens of thousands documents through terminal, and I've sent some of searching queries and some of it wasn't going well even though my terminal process was fully completed.

I can notice that the size of node's folder is getting bigger and bigger till some point.

Is it typical phenomenon because it needs some time for the inner creation process?

If so, is there any method to confirm my documents are actually have been created and all of searching queries are perform perfectly ?

I don't think the size of the data folder is a useful metric here. There are background processes that might change the data on disk even if you are doing nothing.

If the response from your POST /_bulk indicated success then the documents were all indexed and will be exposed to searches after the next refresh.

1 Like

Very much thank you David!

Yours sincerely

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