I'm trying to add new values to an existing array field in a document. I've
noticed that using the update api just overwrites the entire array field.
So far all the examples I have found are using scripting but I can't do
that because of security. Adding the script in the config/script folder as
per http://www.elasticsearch.org/blog/scripting-security/ is not ideal
because that would mean I would be required to manually place the script in
wherever our ES instances would be installed, which could be alot of
places.
I'm actually using the Apache HttpClient to make http calls for GET and
POST etc., and a way around this is to make multiple requests in order to
get the existing array, update it from Java code, and then send a request
with the updated array. However I do not like this approach as I end up
making more than one request. I do not want to use the Java API for this
(even if there is a way).
Just another note. A sequence of GET and POST can cause concurrency issues
if more than one of our application nodes are communicating with the ES
instance, if they try update at the same/similar time, so this is really
not ideal.
The current default scripting language, groovy, is sandboxed. If you still
don't want to use it your only option is the get update put sequence.
On Jan 19, 2015 1:29 PM, "Jason Lee" pump.mini90@gmail.com wrote:
I'm trying to add new values to an existing array field in a document.
I've noticed that using the update api just overwrites the entire array
field. So far all the examples I have found are using scripting but I can't
do that because of security. Adding the script in the config/script folder
as per Elasticsearch Platform — Find real-time answers at scale | Elastic is not ideal
because that would mean I would be required to manually place the script in
wherever our ES instances would be installed, which could be alot of
places.
I'm actually using the Apache HttpClient to make http calls for GET and
POST etc., and a way around this is to make multiple requests in order to
get the existing array, update it from Java code, and then send a request
with the updated array. However I do not like this approach as I end up
making more than one request. I do not want to use the Java API for this
(even if there is a way).
Ah ok, so I don't have to worry about any security risks then if I just use
the defaults?
On Thursday, January 22, 2015 at 10:50:32 AM UTC+13, Nikolas Everett wrote:
The current default scripting language, groovy, is sandboxed. If you still
don't want to use it your only option is the get update put sequence.
On Jan 19, 2015 1:29 PM, "Jason Lee" <pump....@gmail.com <javascript:>>
wrote:
I'm trying to add new values to an existing array field in a document.
I've noticed that using the update api just overwrites the entire array
field. So far all the examples I have found are using scripting but I can't
do that because of security. Adding the script in the config/script folder
as per Elasticsearch Platform — Find real-time answers at scale | Elastic is not
ideal because that would mean I would be required to manually place the
script in wherever our ES instances would be installed, which could be alot
of places.
I'm actually using the Apache HttpClient to make http calls for GET and
POST etc., and a way around this is to make multiple requests in order to
get the existing array, update it from Java code, and then send a request
with the updated array. However I do not like this approach as I end up
making more than one request. I do not want to use the Java API for this
(even if there is a way).
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.