Hi, I have to update a document in my Java app, using the Rest High Level Client.
I must to override the document, i.e.: I need to replace completely the document with a new version.
I am trying this but it only makes a partial update:
The Update API allows to update an existing document by using a script or by passing a partial document.
That's because the client matches Elasticsearch's own Update API:
Enables you to script document updates. The script can update, delete, or skip modifying the document. The update API also supports passing a partial document, which is merged into the existing document. To fully replace an existing document, use the index API.
OK, as per the last sentence, to replace a doc (i.e. PUT /your_index/_doc/yourdocID) you need to use the high-level REST client's Index API instead of Update.
You might think of indexing as only creating docs, but it's also replacing them. You can even control this via an optional argument. Look for request.opType. But you don't need to change this. The default value allows creating or replacing a doc which works for you.
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.