Question on function score script


(Amit Soni) #1

Hi everyone - I am facing an error when executing a function score query
and just wanted to get your comments on the same.

This is the script:
"script_score": {
"script": "doc['boostValue'].value >0 ? ( _score *
doc['boostValue'].value ) : _score"
}

It primarily says that if the boostValue is positive, then multiply _score
by it else use _score as is. The error I get is below:

reason: QueryPhaseExecutionException[[index_type_1][0]: query[function
score (filtered(website:bank
name:bank)->cache(region:US),function=script[doc['boostValue'].value >0 ? (
_score * doc['boostValue'].value ) : _score], params
[null])],from[0],size[5]: Query Failed [Failed to execute main query]];
nested: PropertyAccessException[[Error: could not access: value; in class:
org.elasticsearch.index.fielddata.ScriptDocValues$Empty] [Near : {...
doc['boostValue'].value >0 ? ( ....}] ^ [Line: 1, Column: 1]];

Any thoughts?

-Amit.

--
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/CAAOGaQ%2B%2BxmQV19xGzKs0NzP2Dufx1S%3DDPeiH018q3itPRxjVxA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Alexander Reelsen) #2

Hey,

most likely some document which matched your query does not contain the
field boostValue...

--Alex

On Thu, Feb 13, 2014 at 8:54 AM, Amit Soni amitsoni29@gmail.com wrote:

Hi everyone - I am facing an error when executing a function score query
and just wanted to get your comments on the same.

This is the script:
"script_score": {
"script": "doc['boostValue'].value >0 ? ( _score *
doc['boostValue'].value ) : _score"
}

It primarily says that if the boostValue is positive, then multiply _score
by it else use _score as is. The error I get is below:

reason: QueryPhaseExecutionException[[index_type_1][0]: query[function
score (filtered(website:bank
name:bank)->cache(region:US),function=script[doc['boostValue'].value >0 ? (
_score * doc['boostValue'].value ) : _score], params
[null])],from[0],size[5]: Query Failed [Failed to execute main query]];
nested: PropertyAccessException[[Error: could not access: value; in class:
org.elasticsearch.index.fielddata.ScriptDocValues$Empty] [Near : {...
doc['boostValue'].value >0 ? ( ....}] ^ [Line: 1, Column: 1]];

Any thoughts?

-Amit.

--
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/CAAOGaQ%2B%2BxmQV19xGzKs0NzP2Dufx1S%3DDPeiH018q3itPRxjVxA%40mail.gmail.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9u1%3DpNqZG_-yrfHia3Y6hOG_6HSxH2gVvtZiEovxP6yw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #3

And you can test for it if needed:

doc['boostValue'].isEmpty()

--
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/267ee0ce-b349-4a75-ae8d-c43d40ffc1d4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Amit Soni) #4

thanks Alex and Binh. I tried with isEmpty() check and it worked fine.

-Amit.

On Thu, Feb 13, 2014 at 5:02 AM, Binh Ly binh@hibalo.com wrote:

And you can test for it if needed:

doc['boostValue'].isEmpty()

--
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/267ee0ce-b349-4a75-ae8d-c43d40ffc1d4%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAAOGaQK4ixbPfBoxQQoEvt26G64N4PkbLndYJOCRGgW%3DV2SH6w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #5