Update By Query to update multiple fields at a time in elastic search
<p>i have a use case of update by query in elastic search.</p>

<p>I am keeping a doc like -</p>

<pre><code>"a" : "1",
"b" : "2",
"version1" : 456
"c" : {
   "version2" : 123,
   "d" : "3"
}
</code></pre>

<p>Now dependently for my use case-</p>

<ol>
<li>I either want to update field a, b and version1</li>
<li>Or I will update field d and version2.</li>
</ol>

<p>I got partial answer in <a href="https://stackoverflow.com/questions/37038887/update-by-query-in-elasticsearch-using-java">Update By Query in Elasticsearch using Java</a>.</p>

<p>I am trying things like this-</p>

<pre><code>    BulkIndexByScrollResponse r = ubqrb.script(script)
        .script(script1)
        .script(script2)
        .script(script3)
        .script(script4)
        .filter(qb).get();
</code></pre>

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

<p>I also tried -</p>

<pre><code>    Script script4 = new Script("ctx._source.a=\"abc\",b=\"xyz\"");
</code></pre>

<p>However this one also failed.</p>

<p>Any idea what can be done using update by where.
Thanks in advance</p>