Updating all data elasticsearch

485 views Asked by At

Is there any way to update all data in elasticsearch.

In below example, update done for external '1'.

curl -XPOST 'localhost:9200/customer/external/1/_update?pretty' -d '
{
 "doc": { "name": "Jane Doe", "age": 20 }
}'

Similarly, I need to update all my data in external. Is there any way or query to updating all data.

1

There are 1 answers

2
Andrei Stefan On

Updating all documents in an index means that all documents will be deleted and new ones will be indexed. Which means lots of "marked-as-deleted" documents.

When you run a query ES will automatically filter out those "marked-as-deleted" documents, which will have an impact on the response time of the query. How much impact it depends on the data, use case and query.

Also, if you update all documents, unless you run a _force_merge there will be segments (especially the larger ones) that will still have "marked-as-deleted" documents and those segments are hard to be automatically merged by Lucene/Elasticsearch.

My suggestion, if your indexing process is not too complex (like getting the data from a relational database and process it before indexing into ES, for example), is to drop the index completely and index fresh data. It might be more effective than updating all the documents.