Accessing Parameter values inside a MVEL script

Hi All,

I am trying to run a faceted query with a custom script on the facet value.
I need to pass a "map" of values into the script with params. Below id my
script,

"value_script":"( iid1= new String(doc['itemid1'].value) ;r =
doc['similarity'].value * srcVals.containsKey(iid1) ? srcVals.get(iid1): -1
; return r )"

For some reason, my containsKey returns true but get on the map results
in a nullpointer exception.

I pass params as :

"params": { "srcVals": sources }

Where sources is a python dict. example dict is:

{'3058211': '3', '3473092': '4', '3097044': '3', '2491239': '4', '2371363':
'4', '3049884': '5', '2212351': '4', '3064057': '3'}

As you can see, i need to get a number associated with some other number. I
pass the association as a param. but accessing the param is returning a
nullpointer.

Thanks!
Ravi

--
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/31746a14-4c9c-4fe3-b8f2-c59947f31706%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Here is my full ES query in python

res1 = es.search(index="myIndex", body={"query":{ "bool": { "must" : {
"terms":{ "type.itemid1":wiids } }, "must_not" : { "terms" : {
"type.itemid2":wiids } } } },"facets":{ "itemid2Stats": {"terms_stats" : {
"key_field": "type.itemid2", "value_script":"( iid1=
doc['itemid1'].value;r = doc['internalScore'].value *
srcVals.containsKey(iid1) ? srcVals.get(iid1): 11; return r )", "params": {
"srcVals": sources }, "size": 1000, "shard_size": 5000 ,"order": "mean"
} } }}, sort=["type.itemid1:desc","type.similarity:desc"], size=1)

and the error i get is:

sort[<custom:"itemid1":
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@64f6e93>!,<custom:"similarity":
org.elasticsearch.index.fielddata.fieldcomparator.FloatValuesComparatorSource@48e47821>!]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}

On Thursday, 15 May 2014 17:26:49 UTC+1, ravim...@gmail.com wrote:

Hi All,

I am trying to run a faceted query with a custom script on the facet
value. I need to pass a "map" of values into the script with params. Below
id my script,

"value_script":"( iid1= new String(doc['itemid1'].value) ;r =
doc['similarity'].value * srcVals.containsKey(iid1) ? srcVals.get(iid1): -1
; return r )"

For some reason, my containsKey returns true but get on the map results
in a nullpointer exception.

I pass params as :

"params": { "srcVals": sources }

Where sources is a python dict. example dict is:

{'3058211': '3', '3473092': '4', '3097044': '3', '2491239': '4',
'2371363': '4', '3049884': '5', '2212351': '4', '3064057': '3'}

As you can see, i need to get a number associated with some other number.
I pass the association as a param. but accessing the param is returning a
nullpointer.

Thanks!
Ravi

--
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/d7753b14-c793-4c45-8aec-ac0fd1b386f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi All,

Any help on this please? Has anyone tried MVEL based scripts that get a
value out of a map?

Thanks!
Ravi

On Thursday, 15 May 2014 17:35:52 UTC+1, ravim...@gmail.com wrote:

Here is my full ES query in python

res1 = es.search(index="myIndex", body={"query":{ "bool": { "must" : {
"terms":{ "type.itemid1":wiids } }, "must_not" : { "terms" : {
"type.itemid2":wiids } } } },"facets":{ "itemid2Stats": {"terms_stats" :
{ "key_field": "type.itemid2", "value_script":"( iid1=
doc['itemid1'].value;r = doc['internalScore'].value *
srcVals.containsKey(iid1) ? srcVals.get(iid1): 11; return r )", "params":
{ "srcVals": sources }, "size": 1000, "shard_size": 5000 ,"order": "mean"
} } }}, sort=["type.itemid1:desc","type.similarity:desc"], size=1)

and the error i get is:

sort[<custom:"itemid1":
org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@64f6e93>!,<custom:"similarity":
org.elasticsearch.index.fielddata.fieldcomparator.FloatValuesComparatorSource@48e47821>!]:
Query Failed [Failed to execute main query]]; nested: NullPointerException;
}

On Thursday, 15 May 2014 17:26:49 UTC+1, ravim...@gmail.com wrote:

Hi All,

I am trying to run a faceted query with a custom script on the facet
value. I need to pass a "map" of values into the script with params. Below
id my script,

"value_script":"( iid1= new String(doc['itemid1'].value) ;r =
doc['similarity'].value * srcVals.containsKey(iid1) ? srcVals.get(iid1): -1
; return r )"

For some reason, my containsKey returns true but get on the map
results in a nullpointer exception.

I pass params as :

"params": { "srcVals": sources }

Where sources is a python dict. example dict is:

{'3058211': '3', '3473092': '4', '3097044': '3', '2491239': '4',
'2371363': '4', '3049884': '5', '2212351': '4', '3064057': '3'}

As you can see, i need to get a number associated with some other number.
I pass the association as a param. but accessing the param is returning a
nullpointer.

Thanks!
Ravi

--
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/3e1051d7-c385-4436-b24a-b3183d904818%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.