Scripting "contains" integer versus long


(eunever32) #1

I have a mvel script (groovy looks the same) as follows:
if (!ctx._source.list.contains(document)) {ctx._source.list +=
document;} else {ctx.op = "none"}";

I have a java map
map.put("id", 100L);

When I try to match the above document to an existing ES document it will
fail because it's a "long".
If both documents are "long" like above the match fails. Mapping doesn't
matter (mapping field with long will still fail)

Using java integer works ie
map.put("id", 100);

It seems the scripts (mvel and groovy) cast the number to integer before
doing the match (?)

This is okay for now but if my numbers exceed the java integer max I will
need a solution.

Regards,

--
Please update your bookmarks! We have moved to https://discuss.elastic.co/

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/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Nik Everett) #2

I suspect at that point they'll pop out as Longs. Its just my suspicion. I
haven't read that bit of the code.
On May 11, 2015 10:08 AM, eunever32@gmail.com wrote:

I have a mvel script (groovy looks the same) as follows:
if (!ctx._source.list.contains(document)) {ctx._source.list +=
document;} else {ctx.op = "none"}";

I have a java map
map.put("id", 100L);

When I try to match the above document to an existing ES document it will
fail because it's a "long".
If both documents are "long" like above the match fails. Mapping doesn't
matter (mapping field with long will still fail)

Using java integer works ie
map.put("id", 100);

It seems the scripts (mvel and groovy) cast the number to integer before
doing the match (?)

This is okay for now but if my numbers exceed the java integer max I will
need a solution.

Regards,

--
Please update your bookmarks! We have moved to https://discuss.elastic.co/

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/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Please update your bookmarks! We have moved to https://discuss.elastic.co/

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/CAPmjWd33B1KG24%2BFfMKm6DhoX2jWYg0jqcZgftcFyWmCiHWx3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(eunever32) #3

I see there are no answers yet. Any help appreciated.

But just to repeat the question:

the mvel script fails to match documents
I have a list in elasticsearch containing longs.
I submit one element in mvel script like this if
(document.contains(element)) { ... }
But it never matches.

If I change my document to integer then the script starts to work.

This means the script requires integer to work
So even though things are working now, if my ES data goes above 2*32 then
the application won't work !

On Monday, May 11, 2015 at 3:16:01 PM UTC+1, Nikolas Everett wrote:

I suspect at that point they'll pop out as Longs. Its just my suspicion. I
haven't read that bit of the code.
On May 11, 2015 10:08 AM, <eune...@gmail.com <javascript:>> wrote:

I have a mvel script (groovy looks the same) as follows:
if (!ctx._source.list.contains(document)) {ctx._source.list +=
document;} else {ctx.op = "none"}";

I have a java map
map.put("id", 100L);

When I try to match the above document to an existing ES document it will
fail because it's a "long".
If both documents are "long" like above the match fails. Mapping doesn't
matter (mapping field with long will still fail)

Using java integer works ie
map.put("id", 100);

It seems the scripts (mvel and groovy) cast the number to integer before
doing the match (?)

This is okay for now but if my numbers exceed the java integer max I will
need a solution.

Regards,

--
Please update your bookmarks! We have moved to
https://discuss.elastic.co/

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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Please update your bookmarks! We have moved to https://discuss.elastic.co/

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/04b1d166-49e4-4414-a1d5-3709449118ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4