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.
Thanks for reply. If i set id with below code. So ideally, i should delete those document which i need to update then index again.
Is this the best approach? What you suggest.
// make sure that these are not null
Preconditions.checkNotNull(indexName);
Preconditions.checkNotNull(type);
Preconditions.checkNotNull(json);
IndexRequestBuilder indexRequestBuilder = manager.getClient()
.prepareIndex(indexName, type)
.setSource(json);
// / They didn't specify an ID, so we will create one for them.
if(id != null)
indexRequestBuilder.setId(id);
if(ts != null)
indexRequestBuilder.setTimestamp(ts);
if(parent != null)
indexRequestBuilder.setParent(parent);
if(routing != null)
indexRequestBuilder.setRouting(routing);
add(indexRequestBuilder.request());
}
If you set the _id then you don't need to delete the document and index it again but just send the index operation again using the same index/type/id and you're done.
Behind the scene, elasticsearch will delete the document and index a new version.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.