Trouble with custom_score query

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' -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' -d
    '{"title":"Grand Theft Auto 4", "alt_title":"GTA 4",
    "some_number":"9.5"}'

  3. curl -XPUT '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' 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=*' 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' -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.

  • deleted -

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