Custom Score script parameter not working


(dark_shadow) #1

Hi,

I'm using following custom score script parameter for customizing the
scoring of my documents.

String script = "doc['po'].value";

But it gives me error that:

[Error: could not access: value; in class:
org.elasticsearch.index.fielddata.ScriptDocValues$Empty

My al documents contain this field but why Elasticsearch is not able to
access the value of this field ?

Any idea ?

I have also included that field in my mapping.
"po": {
"type": "double",
"boost": 4.0
}

We can use boost for such a field right ?

Thanks

--
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/972b4f45-1512-4932-9bcb-6fc5cce30fb2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #2

That means you have some documents in your index that is missing the "po"
field. You should be able to run a query like this to find out:

{
"query": {
"filtered": {
"filter": {
"missing": {
"field": "po"
}
}
}
}
}

--
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/2dfda36e-1a24-41d8-9bf2-80cff402090a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(dark_shadow) #3

I don't have any document for which po field is empty. I have checked my
mongo collections. Also, earlier it was taking value 1 for all the
documents that was the reason why _score was same for all the documents. Is
there anything wrong in my mapping field which is causing issue ? Please
help me.

On Thu, Jan 30, 2014 at 6:32 PM, Binh Ly binh@hibalo.com wrote:

That means you have some documents in your index that is missing the "po"
field. You should be able to run a query like this to find out:

{
"query": {
"filtered": {
"filter": {
"missing": {
"field": "po"
}
}
}
}
}

--
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/2dfda36e-1a24-41d8-9bf2-80cff402090a%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/CAAVTvp5ie_dptgPyXaBV1sc_Efh%3DDDYZyDp5ST%2BNByd60KCzZw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(dark_shadow) #4

I'm shocked what really is happening.

The output of above query shows all my documents are missing that
particular field value.

{"took":222,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":4185107,"max_score":1.0,"hits":[{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49ce64bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49ce64bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"dindigul
to guntur driving
directions","url":"/driving-direction-by-road-route-map/dindigul-to-guntur-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49ce74bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49ce74bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"dindigul
to solapur driving
directions","url":"/driving-direction-by-road-route-map/dindigul-to-solapur-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49ce84bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49ce84bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"diu
to kanyakumari driving
directions","url":"/driving-direction-by-road-route-map/diu-to-kanyakumari-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49ce94bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49ce94bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"diu
to yellapur driving
directions","url":"/driving-direction-by-road-route-map/diu-to-yellapur-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49cea4bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49cea4bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"dombivli
to mahabaleshwar driving
directions","url":"/driving-direction-by-road-route-map/dombivli-to-mahabaleshwar-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49ceb4bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49ceb4bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"dungarpur
to bhadrachalam driving
directions","url":"/driving-direction-by-road-route-map/dungarpur-to-bhadrachalam-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49cec4bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49cec4bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"dungarpur
to palakkad driving
directions","url":"/driving-direction-by-road-route-map/dungarpur-to-palakkad-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49ced4bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49ced4bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"durg
to dehradun driving
directions","url":"/driving-direction-by-road-route-map/durg-to-dehradun-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49cee4bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49cee4bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"durg
to sakleshpur driving
directions","url":"/driving-direction-by-road-route-map/durg-to-sakleshpur-driving-directions"}},{"_index":"acqindex","_type":"autocomplete_questions","_id":"50efe5637d5cb0e49cef4bfb","_score":1.0,
"_source" :
{"_id":"50efe5637d5cb0e49cef4bfb","count":0.0,"ctype":"driving","en":true,"po":6.1923076923076925,"text":"durgapur
to hyderabad driving
directions","url":"/driving-direction-by-road-route-map/durgapur-to-hyderabad-driving-directions"}}]}}

This is really weird !!!

On Thu, Jan 30, 2014 at 6:48 PM, Mukul Gupta mukulnitkkr@gmail.com wrote:

I don't have any document for which po field is empty. I have checked my
mongo collections. Also, earlier it was taking value 1 for all the
documents that was the reason why _score was same for all the documents. Is
there anything wrong in my mapping field which is causing issue ? Please
help me.

On Thu, Jan 30, 2014 at 6:32 PM, Binh Ly binh@hibalo.com wrote:

That means you have some documents in your index that is missing the "po"
field. You should be able to run a query like this to find out:

{
"query": {
"filtered": {
"filter": {
"missing": {
"field": "po"
}
}
}
}
}

--
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/2dfda36e-1a24-41d8-9bf2-80cff402090a%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/CAAVTvp6DK2nH1UL5QFuNX1SYm0QHD6zy3w%3DyN4JPh-_Z97o-hA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #5

That's strange. May I ask which version of ES are you using? Thanks.

--
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/cfab1687-44ed-43d2-9917-caaea488cfeb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(dark_shadow) #6

I'm using elasticsearch-0.90.3.

On Thu, Jan 30, 2014 at 7:14 PM, Binh Ly binh@hibalo.com wrote:

That's strange. May I ask which version of ES are you using? Thanks.

--
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/cfab1687-44ed-43d2-9917-caaea488cfeb%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/CAAVTvp5V4ttNv%2B3NHTbVQeQD6SnqMRHqaZFbVYMt3XSEz9DcHA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(dark_shadow) #7

Can anyone please tell me if this is a bug in ElasticSearch-0.90.3 ?
ElasticSearch is not able to read the value of a field from the doc. How is
it possible ?

On Thu, Jan 30, 2014 at 7:56 PM, Mukul Gupta mukulnitkkr@gmail.com wrote:

I'm using elasticsearch-0.90.3.

On Thu, Jan 30, 2014 at 7:14 PM, Binh Ly binh@hibalo.com wrote:

That's strange. May I ask which version of ES are you using? Thanks.

--
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/cfab1687-44ed-43d2-9917-caaea488cfeb%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/CAAVTvp6FY4QMymvN7zSb7jArv1Umd%2BS%3D-Voy2JNfkzVLrnWUDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #8

Coder, I can duplicate your problem. I am trying to find out if this is a
bug, or it is by design and will get back to you shortly. Thanks.

--
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/27ee812c-521c-4ff5-bb66-20b32a1f2672%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Jörg Prante) #9

I think the apostrophe is your problem

It is not

String script = "doc['po'].value";

but

String script = "doc["po"].value";

For implementing best variant of document boost, you should upgrade
Elasticsearch to 1.0.0.RC1 (or 0.90.4+) and use function score query like
this

Jörg

On Thu, Jan 30, 2014 at 8:17 PM, Mukul Gupta mukulnitkkr@gmail.com wrote:

Can anyone please tell me if this is a bug in ElasticSearch-0.90.3 ?
ElasticSearch is not able to read the value of a field from the doc. How is
it possible ?

--
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/CAKdsXoHO7eX_2%2BmRMzM%2BHa_K4ZfhDBsV_N%3D3MQukQ9eXsM1Avg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #10