Hi,
Is there any way to achieve "set" operation on elasticsearch document field, means field having unique list of values. I am able to update document but facing duplicates issue.
//field value before update {"skills":["JAVA","HADOOP"]}
Map<String, String> params = ImmutableMap.of("skill", "JAVA");
client.prepareUpdate("index", "type", "id")
.setScript(new Script("ctx._source.skills+=skill", ScriptService.ScriptType.INLINE, null, params))
.get();
//field value after update {"skills":["JAVA","HADOOP","JAVA"]}
//expected field value after update without duplicates {"skills":["JAVA","HADOOP"]}
Can anybody please suggest if we have a way or must get previous value and have to re-construct then over-write it back.
Thanks.