Scripting nested docs array with javascript plugin

Hey, all. I'm tired of dealing with mvel, and moved to scripting with
javascript.
The issue is that I cannot use simple array functions, even like push to
push an element to the end of array.

Here's an exception that I'm getting when tried to splice element by index
from the array of nested docs:
{
"error" : "ElasticSearchIllegalArgumentException[failed to execute
script]; nested: EcmaError[TypeError: Cannot call property splice in object
null. It is not a function, it is "undefined". (Script1.js#1)]; ",
"status" : 400
}

ctx._source.my_array.splice(index, 1)

Everything I try returns me 'Cannot call property %method_name% in object
null. It is not a function, it is "undefined"', even though I can
iterate over the array and set values by index, i.e:
ctx._source.my_array[index] = some_doc;

Can anybody help me, please?

I am having the exact same issue. Did you ever resolve it?

-K

On Friday, July 13, 2012 1:46:09 AM UTC-7, Rauan Maemirov wrote:

Hey, all. I'm tired of dealing with mvel, and moved to scripting with
javascript.
The issue is that I cannot use simple array functions, even like push to
push an element to the end of array.

Here's an exception that I'm getting when tried to splice element by index
from the array of nested docs:
{
"error" : "ElasticSearchIllegalArgumentException[failed to execute
script]; nested: EcmaError[TypeError: Cannot call property splice in object
null. It is not a function, it is "undefined". (Script1.js#1)]; ",
"status" : 400
}

ctx._source.my_array.splice(index, 1)

Everything I try returns me 'Cannot call property %method_name% in object
null. It is not a function, it is "undefined"', even though I can
iterate over the array and set values by index, i.e:
ctx._source.my_array[index] = some_doc;

Can anybody help me, please?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi, Kai. Yeah, I ended up iterating and adding value by index.

2013/5/13 Kai Cherry rnsksoft@gmail.com

I am having the exact same issue. Did you ever resolve it?

-K

On Friday, July 13, 2012 1:46:09 AM UTC-7, Rauan Maemirov wrote:

Hey, all. I'm tired of dealing with mvel, and moved to scripting with
javascript.
The issue is that I cannot use simple array functions, even like push to
push an element to the end of array.

Here's an exception that I'm getting when tried to splice element by
index from the array of nested docs:
{
"error" : "ElasticSearchIllegalArgumentException[failed to execute
script]; nested: EcmaError[TypeError: Cannot call property splice in object
null. It is not a function, it is "undefined". (Script1.js#1)]; ",
"status" : 400
}

ctx._source.my_array.splice(**index, 1)

Everything I try returns me 'Cannot call property %method_name% in object
null. It is not a function, it is "undefined"', even though I can
iterate over the array and set values by index, i.e:
ctx._source.my_array[index] = some_doc;

Can anybody help me, please?

--
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/7ekxjyUjtH8/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.