Custom_score troubles


(Michael Korbakov) #1

Hi everybody.

I'm having some strange problems with custom_score queries.

My query is {"query": {"custom_score": {"query": {"query_string":
{"default_field": "keywords.kwds.tail", "query": "maxim"}}, "script" :
"score * doc['online']['rating'].value"}}}

My index contains one single document and this document is matched by
query_string part of query. Index's mapping is all default. However
before-mentioned query gives me the following error:

rmihael@Lasombra tmp $ curl http://localhost:9200/standard/_search?pretty=on
-d @query
{
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [ {
"index" : "standard",
"shard" : 0,
"reason" : "RemoteTransportException[[Jonas Harrow][inet[/
10.37.129.2:9301]][search/phase/query]]; nested:
QueryPhaseExecutionException[[standard][0]: query[custom score
(keywords.kwds.tail:maxim,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser
$ScriptScoreFunction@6127d470)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: CompileException[[Error: No field
found for [online]]\n[Near : {... Unknown ....}]\n ^
\n[Line: 1, Column: 0]]; nested:
ElasticSearchIllegalArgumentException[No field found for [online]]; "
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

'online' field is certainly in the document:

rmihael@Lasombra tmp $ curl http://localhost:9200/standard/_search?pretty=on
-d '{"query": {"match_all": {}}}'
{
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "standard",
"_type" : "image",
"_id" : "870230",
"_score" : 1.0, "_source" : {"created": "2006-06-30 13:48:35",
"in_collection": false, "image": {"isolated": false}, "online":
{"rating": 2, "nb_views": 162, "nb_downloads": 1}, "content":
{"content_is_exclusive": true, "orientation": "horizontal",
"has_releases": false, "country_id": "643", "is_offensive": false,
"panoramic": true, "offensive_level": 0, "member_is_exclusive":
false}, "prices": {"extended": 20, "min": 1, "max": 20, "M": 5, "L":
7, "S": 3, "X": 20, "XS": 1}, "keywords": {"kwds": {"head7":
"celebrate", "head6": "fruit", "head5": "food", "head4": "strawberry",
"head3": "background", "head2": "arrow", "head1": "alcohol", "tail":
["chilly", "christmas", "cold", "crystal", "december", "decorate",
"decoration", "diamond", "drink", "fashion", "february", "festive",
"flake", "frame", "gift", "glass", "glitter", "green", "hat",
"holiday", "isolated", "january", "jewel", "leisure", "new",
"ornament", "party", "pin", "present", "red", "reflect", "retro",
"romantic", "season", "silver", "snowflake", "sparkle", "stick",
"stir", "style", "valentine", "vintage", "white", "winter", "years",
"maxim mukhin"]}, "original_kwds": {"head7": "christmas", "head6":
"chilly", "head5": "celebrate", "head4": "background", "head3":
"strawberry", "head2": "alcohol", "head1": "arrow", "tail": ["cold",
"crystal", "december", "decorate", "decoration", "diamond", "drink",
"fashion", "february", "festive", "flake", "frame", "gift", "glass",
"glitter", "green", "hat", "holiday", "isolated", "january", "jewel",
"new", "ornament", "party", "pin", "present", "red", "reflect",
"retro", "romantic", "season", "silver", "snowflake", "sparkle",
"stary", "stick", "stir", "style", "swizzle", "valentine", "vintage",
"white", "winter", "years"]}, "language_id": "2", "kwds_count": 51,
"relevance_ratio": 1.0}, "member_id": "81209",
"data_computed_timestamp": 1282164649, "licenses": {"extended": true,
"size": "L"}, "content_id": "870230", "categories": {"conceptual":
{"depth3": "737", "depth2": "700", "depth4": "742"}, "representative":
{"depth3": "360", "depth2": "349", "depth4": "373"}}}
} ]
}
}

Any suggestions on this issue?

Thanks in advance,

-- Michael Korbakov


(Shay Banon) #2

The doc element actually works on the fields created in the index (maps to
the index name created). So, in your case, you would put
doc['online.rating'].value

-shay.banon

On Thu, Sep 2, 2010 at 6:26 PM, rmihael rmihael@gmail.com wrote:

Hi everybody.

I'm having some strange problems with custom_score queries.

My query is {"query": {"custom_score": {"query": {"query_string":
{"default_field": "keywords.kwds.tail", "query": "maxim"}}, "script" :
"score * doc['online']['rating'].value"}}}

My index contains one single document and this document is matched by
query_string part of query. Index's mapping is all default. However
before-mentioned query gives me the following error:

rmihael@Lasombra tmp $ curl
http://localhost:9200/standard/_search?pretty=on
-d @query
{
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [ {
"index" : "standard",
"shard" : 0,
"reason" : "RemoteTransportException[[Jonas Harrow][inet[/
10.37.129.2:9301]][search/phase/query]]; nested:
QueryPhaseExecutionException[[standard][0]: query[custom score

(keywords.kwds.tail:maxim,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser
$ScriptScoreFunction@6127d470)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: CompileException[[Error: No field
found for [online]]\n[Near : {... Unknown ....}]\n ^
\n[Line: 1, Column: 0]]; nested:
ElasticSearchIllegalArgumentException[No field found for [online]]; "
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

'online' field is certainly in the document:

rmihael@Lasombra tmp $ curl
http://localhost:9200/standard/_search?pretty=on
-d '{"query": {"match_all": {}}}'
{
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "standard",
"_type" : "image",
"_id" : "870230",
"_score" : 1.0, "_source" : {"created": "2006-06-30 13:48:35",
"in_collection": false, "image": {"isolated": false}, "online":
{"rating": 2, "nb_views": 162, "nb_downloads": 1}, "content":
{"content_is_exclusive": true, "orientation": "horizontal",
"has_releases": false, "country_id": "643", "is_offensive": false,
"panoramic": true, "offensive_level": 0, "member_is_exclusive":
false}, "prices": {"extended": 20, "min": 1, "max": 20, "M": 5, "L":
7, "S": 3, "X": 20, "XS": 1}, "keywords": {"kwds": {"head7":
"celebrate", "head6": "fruit", "head5": "food", "head4": "strawberry",
"head3": "background", "head2": "arrow", "head1": "alcohol", "tail":
["chilly", "christmas", "cold", "crystal", "december", "decorate",
"decoration", "diamond", "drink", "fashion", "february", "festive",
"flake", "frame", "gift", "glass", "glitter", "green", "hat",
"holiday", "isolated", "january", "jewel", "leisure", "new",
"ornament", "party", "pin", "present", "red", "reflect", "retro",
"romantic", "season", "silver", "snowflake", "sparkle", "stick",
"stir", "style", "valentine", "vintage", "white", "winter", "years",
"maxim mukhin"]}, "original_kwds": {"head7": "christmas", "head6":
"chilly", "head5": "celebrate", "head4": "background", "head3":
"strawberry", "head2": "alcohol", "head1": "arrow", "tail": ["cold",
"crystal", "december", "decorate", "decoration", "diamond", "drink",
"fashion", "february", "festive", "flake", "frame", "gift", "glass",
"glitter", "green", "hat", "holiday", "isolated", "january", "jewel",
"new", "ornament", "party", "pin", "present", "red", "reflect",
"retro", "romantic", "season", "silver", "snowflake", "sparkle",
"stary", "stick", "stir", "style", "swizzle", "valentine", "vintage",
"white", "winter", "years"]}, "language_id": "2", "kwds_count": 51,
"relevance_ratio": 1.0}, "member_id": "81209",
"data_computed_timestamp": 1282164649, "licenses": {"extended": true,
"size": "L"}, "content_id": "870230", "categories": {"conceptual":
{"depth3": "737", "depth2": "700", "depth4": "742"}, "representative":
{"depth3": "360", "depth2": "349", "depth4": "373"}}}
} ]
}
}

Any suggestions on this issue?

Thanks in advance,

-- Michael Korbakov


(Michael Korbakov) #3

Thank you! It worked :slight_smile:

On Thu, Sep 2, 2010 at 9:46 PM, Shay Banon shay.banon@elasticsearch.comwrote:

The doc element actually works on the fields created in the index (maps to
the index name created). So, in your case, you would put
doc['online.rating'].value

-shay.banon

On Thu, Sep 2, 2010 at 6:26 PM, rmihael rmihael@gmail.com wrote:

Hi everybody.

I'm having some strange problems with custom_score queries.

My query is {"query": {"custom_score": {"query": {"query_string":
{"default_field": "keywords.kwds.tail", "query": "maxim"}}, "script" :
"score * doc['online']['rating'].value"}}}

My index contains one single document and this document is matched by
query_string part of query. Index's mapping is all default. However
before-mentioned query gives me the following error:

rmihael@Lasombra tmp $ curl
http://localhost:9200/standard/_search?pretty=on
-d http://localhost:9200/standard/_search?pretty=on-d @query
{
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [ {
"index" : "standard",
"shard" : 0,
"reason" : "RemoteTransportException[[Jonas Harrow][inet[/
10.37.129.2:9301]][search/phase/query]]; nested:
QueryPhaseExecutionException[[standard][0]: query[custom score

(keywords.kwds.tail:maxim,function=org.elasticsearch.index.query.xcontent.CustomScoreQueryParser
$ScriptScoreFunction@6127d470)],from[0],size[10]: Query Failed [Failed
to execute main query]]; nested: CompileException[[Error: No field
found for [online]]\n[Near : {... Unknown ....}]\n ^
\n[Line: 1, Column: 0]]; nested:
ElasticSearchIllegalArgumentException[No field found for [online]]; "
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

'online' field is certainly in the document:

rmihael@Lasombra tmp $ curl
http://localhost:9200/standard/_search?pretty=on
-d http://localhost:9200/standard/_search?pretty=on-d '{"query":
{"match_all": {}}}'
{
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "standard",
"_type" : "image",
"_id" : "870230",
"_score" : 1.0, "_source" : {"created": "2006-06-30 13:48:35",
"in_collection": false, "image": {"isolated": false}, "online":
{"rating": 2, "nb_views": 162, "nb_downloads": 1}, "content":
{"content_is_exclusive": true, "orientation": "horizontal",
"has_releases": false, "country_id": "643", "is_offensive": false,
"panoramic": true, "offensive_level": 0, "member_is_exclusive":
false}, "prices": {"extended": 20, "min": 1, "max": 20, "M": 5, "L":
7, "S": 3, "X": 20, "XS": 1}, "keywords": {"kwds": {"head7":
"celebrate", "head6": "fruit", "head5": "food", "head4": "strawberry",
"head3": "background", "head2": "arrow", "head1": "alcohol", "tail":
["chilly", "christmas", "cold", "crystal", "december", "decorate",
"decoration", "diamond", "drink", "fashion", "february", "festive",
"flake", "frame", "gift", "glass", "glitter", "green", "hat",
"holiday", "isolated", "january", "jewel", "leisure", "new",
"ornament", "party", "pin", "present", "red", "reflect", "retro",
"romantic", "season", "silver", "snowflake", "sparkle", "stick",
"stir", "style", "valentine", "vintage", "white", "winter", "years",
"maxim mukhin"]}, "original_kwds": {"head7": "christmas", "head6":
"chilly", "head5": "celebrate", "head4": "background", "head3":
"strawberry", "head2": "alcohol", "head1": "arrow", "tail": ["cold",
"crystal", "december", "decorate", "decoration", "diamond", "drink",
"fashion", "february", "festive", "flake", "frame", "gift", "glass",
"glitter", "green", "hat", "holiday", "isolated", "january", "jewel",
"new", "ornament", "party", "pin", "present", "red", "reflect",
"retro", "romantic", "season", "silver", "snowflake", "sparkle",
"stary", "stick", "stir", "style", "swizzle", "valentine", "vintage",
"white", "winter", "years"]}, "language_id": "2", "kwds_count": 51,
"relevance_ratio": 1.0}, "member_id": "81209",
"data_computed_timestamp": 1282164649, "licenses": {"extended": true,
"size": "L"}, "content_id": "870230", "categories": {"conceptual":
{"depth3": "737", "depth2": "700", "depth4": "742"}, "representative":
{"depth3": "360", "depth2": "349", "depth4": "373"}}}
} ]
}
}

Any suggestions on this issue?

Thanks in advance,

-- Michael Korbakov


(system) #4