'Where clause in elasticsearch UpdateRequest
I have an elasticsearch index where the id is auto-generated. When the need comes to update any document I have to search the document (using other parameters) to get the id first and then use this id in the update request.
Is there a way in which I can provide the where clause in update request itself?
Solution 1:[1]
You can use the Script functionality of UpdateRequest. The where condition can be provided using if statement.
Example:
updateRequest.script(new Script(ScriptType.INLINE, "painless",
"if (ctx._source.userName== 'XXX') {ctx._source.age= '21'}",Collections.emptyMap()));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tyler2P |
