CustomScoreQueryBuilder param values unexpectedly cast to java.lang.String


(Alex-2) #1

The parameter values added to a CustomScoreQueryBuilder by
using .param(java.lang.String key, java.lang.Object value) end up being
Strings when retrieved in an implementation of, for example,
AbstractDoubleSearchScript. Somewhere the values are cast to
java.lang.String, but I couldn't find where. Is this behavior expected?

Cheers
Alex


(Shay Banon) #2

No, it should maintain its native type (i.e. Double, or Integer). Can you
open an issue, I will have a look...

On Wed, Nov 2, 2011 at 12:15 AM, Alex
alessandro.usseglioviretta@gmail.comwrote:

The parameter values added to a CustomScoreQueryBuilder by
using .param(java.lang.String key, java.lang.Object value) end up being
Strings when retrieved in an implementation of, for example,
AbstractDoubleSearchScript. Somewhere the values are cast to
java.lang.String, but I couldn't find where. Is this behavior expected?

Cheers
Alex


(Alex-2) #3

alright, this is the Scala code to replicate the problem


and here is the stack trace

Cheers
Alex


(Alex-2) #4

Double and Int work as expected. Are there limitations in the types that
can be used?

Alex


(Alex-2) #5

A hint that might help solve the riddle: if the value placed into the param
is a java.util.HashMap instead of Test,
that is .param("test", someHashMap<String, Test>)), it works as expected.

Alex


(Shay Banon) #6

The parameters supported are only the ones supported by "json", i.e. native
types (numeric, string), and map/lists. Are you trying to pass a "custom"
class? In this case, it will just pass the "toString" representation of it.

On Wed, Nov 2, 2011 at 3:31 AM, Alex
alessandro.usseglioviretta@gmail.comwrote:

A hint that might help solve the riddle: if the value placed into the
param is a java.util.HashMap instead of Test,
that is .param("test", someHashMap<String, Test>)), it works as expected.

Alex


(Alex-2) #7

ok, that makes sense. Thanks!

Alex


(system) #8