script_fields just adds the field to the search result which it looks like it did properly. I think what you are looking for is update by query which is a feature coming in 2.3 and 5.0.
Also I have one query : even if we update a document via script is it that the old document is deleted and updated document is re indexed like fresh. And so updating a doc is more time taking?
Yes at this moment, I am using update api only for all documents. But I am having an issue.
When I am updating this document via below script, then at same time may be there is another update at that index via java update api.
Issue : sometimes i see the new fields get created but some times not, but if i re run the script, it gets created . And we run query only well the condition written in script meets. (But still we have if condition in script to be double sure). Is it due to the case that may be at same time some other thread trying to update the same document ?
You should wrap code blocks in ``` so they are readable, please.
You should check the responses on those update requests - if you see any version conflicts then you know that an in flight conflict caused the trouble. There is a retry_on_conflict parameter you can use to retry the script.
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.