scripting "contains" integer versus long

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

scripting "contains" integer versus long

eunever32

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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: scripting "contains" integer versus long

Nikolas Everett

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, <[hidden email]> 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 [hidden email].
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.

--
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: scripting "contains" integer versus long

eunever32
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, <<a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="rtZVsqnZfVsJ">eune...@...> 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 <a onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fdiscuss.elastic.co%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFguF42tUvBArAl-xFnDHHIi5v0cA';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fdiscuss.elastic.co%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFguF42tUvBArAl-xFnDHHIi5v0cA';return true;" href="https://discuss.elastic.co/" target="_blank" rel="nofollow">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 <a onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="rtZVsqnZfVsJ">elasticsearc...@googlegroups.com.
To view this discussion on the web visit <a onmousedown="this.href='https://groups.google.com/d/msgid/elasticsearch/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" onclick="this.href='https://groups.google.com/d/msgid/elasticsearch/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" href="https://groups.google.com/d/msgid/elasticsearch/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow">https://groups.google.com/d/msgid/elasticsearch/939d94b5-55b7-4e62-9b20-2f60bf7fdf1f%40googlegroups.com.
For more options, visit <a onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" href="https://groups.google.com/d/optout" target="_blank" rel="nofollow">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 [hidden email].
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.