1

i have a use case of update by query in elastic search.

I am keeping a doc like -

"a" : "1",
"b" : "2",
"version1" : 456
"c" : {
   "version2" : 123,
   "d" : "3"
}

Now dependently for my use case-

  1. I either want to update field a, b and version1
  2. Or I will update field d and version2.

I got partial answer in Update By Query in Elasticsearch using Java.

I am trying things like this-

    BulkIndexByScrollResponse r = ubqrb.script(script)
        .script(script1)
        .script(script2)
        .script(script3)
        .script(script4)
        .filter(qb).get();

However UpdateByQueryRequestBuilder doesn't allow me to give multiple scripts and only and last one, ie script4 is used and rest are neglected.

I also tried -

    Script script4 = new Script("ctx._source.a=\"abc\",b=\"xyz\"");

However this one also failed.

Any idea what can be done using update by where. Thanks in advance

Community
  • 1
  • 1

1 Answers1

0

Try :

new Script("ctx._source.a=\"abc\"; ctx._source.b=\"xyz\"");
harsh tibrewal
  • 785
  • 6
  • 21