# Custom Score script parameter not working

**URL:** https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492
**Category:** Elasticsearch
**Created:** [January 30, 2014, 8:07am UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492 "2014-01-30T08:07:46Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)
#### Post date: [January 30, 2014, 8:07am UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/1 "2014-01-30T08:07:46Z")

</div>

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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)
#### Post date: [January 30, 2014, 1:02pm UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/2 "2014-01-30T13:02:58Z")

</div>

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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)
#### Post date: [January 30, 2014, 1:18pm UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/3 "2014-01-30T13:18:38Z")

</div>

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](mailto: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](mailto: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](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](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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)
#### Post date: [January 30, 2014, 1:22pm UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/4 "2014-01-30T13:22:55Z")

</div>

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](mailto: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](mailto: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](mailto: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](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](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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)
#### Post date: [January 30, 2014, 1:44pm UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/5 "2014-01-30T13:44:52Z")

</div>

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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)
#### Post date: [January 30, 2014, 2:26pm UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/6 "2014-01-30T14:26:49Z")

</div>

I'm using elasticsearch-0.90.3.

On Thu, Jan 30, 2014 at 7:14 PM, Binh Ly [binh@hibalo.com](mailto: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](mailto: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](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](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5V4ttNv%2B3NHTbVQeQD6SnqMRHqaZFbVYMt3XSEz9DcHA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5V4ttNv%2B3NHTbVQeQD6SnqMRHqaZFbVYMt3XSEz9DcHA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)
#### Post date: [January 30, 2014, 7:17pm UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/7 "2014-01-30T19:17:03Z")

</div>

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](mailto: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](mailto: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](mailto: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](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](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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)
#### Post date: [January 30, 2014, 7:27pm UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/8 "2014-01-30T19:27:22Z")

</div>

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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [January 31, 2014, 10:20am UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/9 "2014-01-31T10:20:41Z")

</div>

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

> <https://gist.github.com/jprante/8728976>

Jörg

On Thu, Jan 30, 2014 at 8:17 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto: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](mailto: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](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](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:53am UTC](https://discuss.elastic.co/t/custom-score-script-parameter-not-working/15492/10 "2017-07-06T01:53:42Z")

</div>


