Use arrays as update parameters with elasticsearch-hadoop-mr


(James Campbell) #1

I would like to update an existing document that has an array from
elasticsearch hadoop.

I notice that I can do that from curl directly, for example:

PUT arraydemo/temp/1
{
"counter" : 1,
"tags" : [ "I am an array", "With Multiple values" ],
"more_tags" : [ "I am a tag" ],
"even_more_tags": "I am a tag too!"
}

GET arraydemo/temp/1

POST arraydemo/temp/1/_update
{
"script" : "tmp = new HashSet(); tmp.addAll(ctx._source.tags); tmp.addAll(new_tags); ctx._source.tags = tmp.toArray()",
"params" : {
"new_tags" : [ "add me", "and me" ]
}
}

However, elasticsearch-hadoop appears to be unable to parse array
parameters, such that an upsert operation from within elasticsearch hadoop
using the same script and a document with the same JSON for parameters
fails.

I created an issue on github (elasticsearch hadoop (#223)), but thought I
should post here for ideas or in case there's a workaround that someone
might know of.

James Campbell

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/70608cbd-5a4d-424e-b04e-6daee8ac0635%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Costin Leau) #2

Hi James,

Fwiw, I plan to address this bug shortly - as you pointed out, the JSON
array needs to be handled separately before passing its content in.

On Thu, Jul 3, 2014 at 8:58 PM, James Campbell james.p.campbell@gmail.com
wrote:

I would like to update an existing document that has an array from
elasticsearch hadoop.

I notice that I can do that from curl directly, for example:

PUT arraydemo/temp/1
{
"counter" : 1,
"tags" : [ "I am an array", "With Multiple values" ],
"more_tags" : [ "I am a tag" ],
"even_more_tags": "I am a tag too!"
}

GET arraydemo/temp/1

POST arraydemo/temp/1/_update
{
"script" : "tmp = new HashSet(); tmp.addAll(ctx._source.tags); tmp.addAll(new_tags); ctx._source.tags = tmp.toArray()",
"params" : {
"new_tags" : [ "add me", "and me" ]
}
}

However, elasticsearch-hadoop appears to be unable to parse array
parameters, such that an upsert operation from within elasticsearch hadoop
using the same script and a document with the same JSON for parameters
fails.

I created an issue on github (elasticsearch hadoop (#223)), but thought I
should post here for ideas or in case there's a workaround that someone
might know of.

James Campbell

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/70608cbd-5a4d-424e-b04e-6daee8ac0635%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/70608cbd-5a4d-424e-b04e-6daee8ac0635%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAJogdmdjfWMk0eKX-PDn7GHhCork0xfryXMTNKsOW9aJs-Gr6g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(James Campbell) #3

Costin--

Great news, thanks for the update!

James

On Sun, Jul 6, 2014 at 4:41 PM, Costin Leau costin.leau@gmail.com wrote:

Hi James,

Fwiw, I plan to address this bug shortly - as you pointed out, the JSON
array needs to be handled separately before passing its content in.

On Thu, Jul 3, 2014 at 8:58 PM, James Campbell <james.p.campbell@gmail.com

wrote:

I would like to update an existing document that has an array from
elasticsearch hadoop.

I notice that I can do that from curl directly, for example:

PUT arraydemo/temp/1
{
"counter" : 1,
"tags" : [ "I am an array", "With Multiple values" ],
"more_tags" : [ "I am a tag" ],
"even_more_tags": "I am a tag too!"
}

GET arraydemo/temp/1

POST arraydemo/temp/1/_update
{
"script" : "tmp = new HashSet(); tmp.addAll(ctx._source.tags); tmp.addAll(new_tags); ctx._source.tags = tmp.toArray()",
"params" : {
"new_tags" : [ "add me", "and me" ]
}
}

However, elasticsearch-hadoop appears to be unable to parse array
parameters, such that an upsert operation from within elasticsearch hadoop
using the same script and a document with the same JSON for parameters
fails.

I created an issue on github (elasticsearch hadoop (#223)), but thought I
should post here for ideas or in case there's a workaround that someone
might know of.

James Campbell

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/70608cbd-5a4d-424e-b04e-6daee8ac0635%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/70608cbd-5a4d-424e-b04e-6daee8ac0635%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/M7Z6lp3Yjo0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAJogdmdjfWMk0eKX-PDn7GHhCork0xfryXMTNKsOW9aJs-Gr6g%40mail.gmail.com
https://groups.google.com/d/msgid/elasticsearch/CAJogdmdjfWMk0eKX-PDn7GHhCork0xfryXMTNKsOW9aJs-Gr6g%40mail.gmail.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CA%2BAQu3yRuVAP7VC3Ozb6Xjy4uG4v%2By2o%3DwkAKnvfB4YL8U71FQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4