# Custom\_score troubles

**URL:** <https://discuss.elastic.co/t/custom-score-troubles/3294>\
**Category:** Elasticsearch\
**Created:** [September 2, 2010, 3:26pm UTC](https://discuss.elastic.co/t/custom-score-troubles/3294 "2010-09-02T15:26:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Korbakov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_korbakov/32/3199_2.png) [@Michael\_Korbakov](https://discuss.elastic.co/u/Michael_Korbakov)\
**Post date:** [September 2, 2010, 3:26pm UTC](https://discuss.elastic.co/t/custom-score-troubles/3294/1 "2010-09-02T15:26:05Z")

</div>

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](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](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

---

<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:** [September 2, 2010, 6:46pm UTC](https://discuss.elastic.co/t/custom-score-troubles/3294/2 "2010-09-02T18:46:11Z")

</div>

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](mailto: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](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](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

---

<div class="post-metadata">

**Author:** ![Michael\_Korbakov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_korbakov/32/3199_2.png) [@Michael\_Korbakov](https://discuss.elastic.co/u/Michael_Korbakov)\
**Post date:** [September 2, 2010, 7:37pm UTC](https://discuss.elastic.co/t/custom-score-troubles/3294/3 "2010-09-02T19:37:33Z")

</div>

Thank you! It worked 🙂

On Thu, Sep 2, 2010 at 9:46 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> 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](mailto: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](http://localhost:9200/standard/_search?pretty=on)  
> > -d [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](http://localhost:9200/standard/_search?pretty=on)  
> > -d [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

---

<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:19am UTC](https://discuss.elastic.co/t/custom-score-troubles/3294/4 "2017-07-06T04:19:48Z")

</div>


