1

We have usecase that data will be updated daily. Some of attributes of document changes and some of new record is there. Is it possible to reindex data with updated value, which is already there and add new reocord. if yes, please explain how.

Is it with update API?

I am indexing like this

 String json = getJsonMapper().writeValueAsString(data);
    bulkRequestBuilder.add(getClient().prepareIndex(indexName, typeName).setSource(json));

I am not passing any id. How can i update this. What is best way

1 Answer 1

2

Elasticsearch uses Apache Lucene underneath the covers. In Lucene documents are immutable.

You can use the Update API for your use case. This API does a delete and save underneath but that doesn't concern you. You can even update a part of the document, which means that Elasticsearch will retrieve the old document, generate the new one, delete the old one and save the new one.

The problem is that for all this to work is that you need to use the same id. If you don't then Elasticsearch will generate one for you if you use the Index API. This means that it will be saved as a new document. The Update API needs the id, otherwise it doesn't know what to update.

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

Comments

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.