0

I have many existing indices partition by date. Eg: index_190901, index_190902,...

And I have an API which takes index_name and doc_id as inputs. User want to update some documents in index by input fields, index_name, doc_id.

I'm trying to update document using the following code:

        updateRequest.index("invalid_daily_index")
          .type("type")
          .id("id")
          .doc(jsonMap)

It works fine if user input existing index but if user input non-existing index, new index with no document will be created.

I know that I can setup auto_create_index but I still want to create index automatically when I insert new documents.

Check if index is existed with client.indices.exists(request, RequestOptions.DEFAULT) is quite expensive. I don't want to check it every request

How to make Elasticsearch to not create new index when I use updateRequest.

1 Answer 1

2

You can block the option to automaticaly create non existing indices by putting false to the action.auto_create_index setting of the cluster

PUT _cluster/settings
{
    "persistent" : { "action.auto_create_index” : "false" }
}

For details take a look at the reference

Sign up to request clarification or add additional context in comments.

1 Comment

But I want to auto create index when I insert

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.