# Trouble with custom\_score query

**URL:** <https://discuss.elastic.co/t/trouble-with-custom-score-query/4580>\
**Category:** Elasticsearch\
**Created:** [June 9, 2011, 12:27am UTC](https://discuss.elastic.co/t/trouble-with-custom-score-query/4580 "2011-06-09T00:27:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thnguyen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thnguyen/32/3207_2.png) [@thnguyen](https://discuss.elastic.co/u/thnguyen)\
**Post date:** [June 9, 2011, 12:27am UTC](https://discuss.elastic.co/t/trouble-with-custom-score-query/4580/1 "2011-06-09T00:27:34Z")

</div>

Can anyone give me any insight why my custom\_score query is failing?  
Here are the steps I'm going through:

1. curl -XPOST '[http://localhost/media/object/\_mapping](http://localhost/media/object/_mapping)' -d '{"object":  
{ "properties":{ "title":{ "type":"string", "store":"yes",  
"index":"analyzed", "analyzer" : "snowball" }, "alt\_title":  
{ "type":"string", "store":"yes", "index":"analyzed", "analyzer" :  
"snowball" }, "some\_number":{ "type":"float", "store":"yes",  
"index":"not\_analyzed"} } } }'

2. curl -XPUT '[http://localhost/media/object/827005](http://localhost/media/object/827005)' -d  
'{"title":"Grand Theft Auto 4", "alt\_title":"GTA 4",  
"some\_number":"9.5"}'

3. curl -XPUT '[http://localhost/media/object/827004](http://localhost/media/object/827004)' -d  
'{"title":"Grand Theft Auto 3", "alt\_title":"GTA 3", "some\_number":5}'

4. curl -XGET '[http://localhost/media/object/\_mapping](http://localhost/media/object/_mapping)' returns a  
response of:

{  
"object":{  
"properties":{  
"title":{  
"store":"yes",  
"analyzer":"snowball",  
"type":"string"  
},  
"some\_number":{  
"store":"yes",  
"type":"float"  
},  
"alt\_title":{  
"store":"yes",  
"analyzer":"snowball",  
"type":"string"  
}  
}  
}  
}

1. curl -XGET '[http://localhost/media/object/\_search?q=\*](http://localhost/media/object/_search?q=*)' returns a  
response of:

{  
"took":2,  
"timed\_out":false,  
"\_shards":{  
"total":3,  
"successful":3,  
"failed":0  
},  
"hits":{  
"total":2,  
"max\_score":1.0,  
"hits":[  
{  
"\_index":"media",  
"\_type":"object",  
"\_id":"827005",  
"\_score":1.0,  
"\_source":{  
"title":"Grand Theft Auto 4",  
"alt\_title":"GTA 4",  
"some\_number":9.5  
}  
},  
{  
"\_index":"media",  
"\_type":"object",  
"\_id":"827004",  
"\_score":1.0,  
"\_source":{  
"title":"Grand Theft Auto 3",  
"alt\_title":"GTA 3",  
"some\_number":5  
}  
}  
]  
}  
}

So far a mapping has been created and two documents have been  
indexed. I then run a custom\_score query search that is returning the  
failure:

curl -XGET '[http://localhost/media/object/\_search](http://localhost/media/object/_search)' -d '{  
"query":{  
"custom\_score":{  
"query":{  
"query\_string":{  
"default\_field":"title",  
"query":"grand theft auto"  
}  
},  
"script":"\_score \* doc['some\_number'].value"  
}  
}  
}'

Response:

{  
"took":6,  
"timed\_out":false,  
"\_shards":{  
"total":3,  
"successful":1,  
"failed":2,  
"failures":[  
{  
"index":"media",  
"shard":0,  
"reason":"QueryPhaseExecutionException[[media][0]:  
query[custom score (title:grand title:theft  
title:auto,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@1ff52524)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: CompileException[[Error: No field  
found for  
[org.elasticsearch.index.field.data.floats.FloatDocFieldData@6beb3926]]  
\n[Near : {... \_score \* doc[some\_number].valu ....}]\n ^  
\n[Line: 1, Column: 1]]; nested:  
ElasticSearchIllegalArgumentException[No field found for  
[org.elasticsearch.index.field.data.floats.FloatDocFieldData@6beb3926]];  
"  
},  
{  
"index":"media",  
"shard":1,  
"reason":"QueryPhaseExecutionException[[media][1]:  
query[custom score (title:grand title:theft  
title:auto,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser  
$ScriptScoreFunction@3512106c)],from[0],size[10]: Query Failed [Failed  
to execute main query]]; nested: CompileException[[Error: No field  
found for  
[org.elasticsearch.index.field.data.floats.FloatDocFieldData@70a26301]]  
\n[Near : {... \_score \* doc[some\_number].valu ....}]\n ^  
\n[Line: 1, Column: 1]]; nested:  
ElasticSearchIllegalArgumentException[No field found for  
[org.elasticsearch.index.field.data.floats.FloatDocFieldData@70a26301]];  
"  
}  
]  
},  
"hits":{  
"total":0,  
"max\_score":null,  
"hits":[

```
  ]

```

}  
}

Any help would be much appreciated.

---

<div class="post-metadata">

**Author:** ![fashionalwallet](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@fashionalwallet](https://discuss.elastic.co/u/fashionalwallet)\
**Post date:** [June 9, 2011, 8:55am UTC](https://discuss.elastic.co/t/trouble-with-custom-score-query/4580/2 "2011-06-09T08:55:12Z")

</div>

- deleted -

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 9, 2011, 6:59pm UTC](https://discuss.elastic.co/t/trouble-with-custom-score-query/4580/3 "2011-06-09T18:59:52Z")

</div>

Its curl being funny with the `'`: \_score \* doc['some\_number'].value, try: \_score \* doc.some\_number.value

On Thursday, June 9, 2011 at 3:27 AM, thnguyen wrote:

> \_score \* doc['some\_number'].value

---

<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, 4:04am UTC](https://discuss.elastic.co/t/trouble-with-custom-score-query/4580/4 "2017-07-06T04:04:14Z")

</div>


