# Need some help with Custom Score Query

**URL:** <https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475>\
**Category:** Elasticsearch\
**Created:** [January 29, 2014, 1:55pm UTC](https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475 "2014-01-29T13:55:37Z")\
**Posts on this page:** 8\
**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 29, 2014, 1:55pm UTC](https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475/1 "2014-01-29T13:55:37Z")

</div>

Hi,

I'm using a custom score query for fetching my results from elasticsearch.  
I used a popularity "po" field for modifying \_script parameter but somehow  
it's not working. I used explain parameter to see how the score is getting  
caluclated but my problem is it doesn't seem to take po into consideration  
while calculating score. I have printed the score calculation for two docs.  
Both have same scores but po field is different for both. Can anyone tell  
me where am I going wrong ?

I'm using the following custom score query in my java code:-  
String script = "\_score \* (doc['po'].empty ? 1 : doc['po'].value ==  
0.0 ? 1 : doc['po'].value)";  
QueryBuilder queryBuilder = QueryBuilders.customScoreQuery(  
QueryBuilders.queryString(query)  
.field("text",30)  
.field("ad")  
.field("st")  
.field("cn")  
.field("co")

.defaultOperator(Operator.AND)).script(script);

{category=Hotel, text=hotels in ranchi, count=45.0,  
\_id=525472d7d4a769f431649936, location={lon=85.33333, lat=23.35}, po=8.8}  
1195.7068 = custom score, product of:  
1195.7068 = script score function: composed of:  
239.14136 = sum of:  
215.63971 = max of:  
215.63971 = sum of:  
18.701233 = weight(text:ho in 170585) [PerFieldSimilarity],  
result of:  
18.701233 = score(doc=170585,freq=1.0 = termFreq=1.0  
), product of:  
0.27964544 = queryWeight, product of:  
2.7864501 = idf(docFreq=960416, maxDocs=5731988)  
0.10035904 = queryNorm  
66.8748 = fieldWeight in 170585, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
2.7864501 = idf(docFreq=960416, maxDocs=5731988)  
24.0 = fieldNorm(doc=170585)  
22.496681 = weight(text:hot in 170585) [PerFieldSimilarity],  
result of:  
22.496681 = score(doc=170585,freq=1.0 = termFreq=1.0  
), product of:  
0.30671278 = queryWeight, product of:  
3.056155 = idf(docFreq=733378, maxDocs=5731988)  
0.10035904 = queryNorm  
73.34772 = fieldWeight in 170585, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
3.056155 = idf(docFreq=733378, maxDocs=5731988)  
24.0 = fieldNorm(doc=170585)  
22.589373 = weight(text:hote in 170585) [PerFieldSimilarity],  
result of:  
22.589373 = score(doc=170585,freq=1.0 = termFreq=1.0  
), product of:  
0.307344 = queryWeight, product of:  
3.0624444 = idf(docFreq=728780, maxDocs=5731988)  
0.10035904 = queryNorm  
73.498665 = fieldWeight in 170585, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
3.0624444 = idf(docFreq=728780, maxDocs=5731988)  
24.0 = fieldNorm(doc=170585)  
22.600088 = weight(text:hotel in 170585) [PerFieldSimilarity],  
result of:  
22.600088 = score(doc=170585,freq=1.0 = termFreq=1.0  
), product of:  
0.30741686 = queryWeight, product of:  
3.0631707 = idf(docFreq=728251, maxDocs=5731988)  
0.10035904 = queryNorm  
73.5161 = fieldWeight in 170585, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
3.0631707 = idf(docFreq=728251, maxDocs=5731988)  
24.0 = fieldNorm(doc=170585)  
129.25233 = weight(text:hotels in 170585) [PerFieldSimilarity],  
result of:  
129.25233 = score(doc=170585,freq=1.0 = termFreq=1.0  
), product of:  
0.73517686 = queryWeight, product of:  
7.3254676 = idf(docFreq=10260, maxDocs=5731988)  
0.10035904 = queryNorm  
175.81122 = fieldWeight in 170585, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
7.3254676 = idf(docFreq=10260, maxDocs=5731988)  
24.0 = fieldNorm(doc=170585)  
23.50164 = max of:  
23.50164 = weight(text:in^30.0 in 170585) [PerFieldSimilarity],  
result of:  
23.50164 = score(doc=170585,freq=1.0 = termFreq=1.0  
), product of:  
0.31348857 = queryWeight, product of:  
30.0 = boost  
3.1236706 = idf(docFreq=685498, maxDocs=5731988)  
0.0033453014 = queryNorm  
74.968094 = fieldWeight in 170585, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
3.1236706 = idf(docFreq=685498, maxDocs=5731988)  
24.0 = fieldNorm(doc=170585)  
1.0 = queryBoost

{category=Hotel, text=hotels in kerala, count=5.0,  
\_id=525472d7d4a769f4316499ca, location={lon=93.95, lat=24.81667},  
po=9.228571428571428}  
1195.7068 = custom score, product of:  
1195.7068 = script score function: composed of:  
239.14136 = sum of:  
215.63971 = max of:  
215.63971 = sum of:  
18.701233 = weight(text:ho in 170733) [PerFieldSimilarity],  
result of:  
18.701233 = score(doc=170733,freq=1.0 = termFreq=1.0  
), product of:  
0.27964544 = queryWeight, product of:  
2.7864501 = idf(docFreq=960416, maxDocs=5731988)  
0.10035904 = queryNorm  
66.8748 = fieldWeight in 170733, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
2.7864501 = idf(docFreq=960416, maxDocs=5731988)  
24.0 = fieldNorm(doc=170733)  
22.496681 = weight(text:hot in 170733) [PerFieldSimilarity],  
result of:  
22.496681 = score(doc=170733,freq=1.0 = termFreq=1.0  
), product of:  
0.30671278 = queryWeight, product of:  
3.056155 = idf(docFreq=733378, maxDocs=5731988)  
0.10035904 = queryNorm  
73.34772 = fieldWeight in 170733, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
3.056155 = idf(docFreq=733378, maxDocs=5731988)  
24.0 = fieldNorm(doc=170733)  
22.589373 = weight(text:hote in 170733) [PerFieldSimilarity],  
result of:  
22.589373 = score(doc=170733,freq=1.0 = termFreq=1.0  
), product of:  
0.307344 = queryWeight, product of:  
3.0624444 = idf(docFreq=728780, maxDocs=5731988)  
0.10035904 = queryNorm  
73.498665 = fieldWeight in 170733, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
3.0624444 = idf(docFreq=728780, maxDocs=5731988)  
24.0 = fieldNorm(doc=170733)  
22.600088 = weight(text:hotel in 170733) [PerFieldSimilarity],  
result of:  
22.600088 = score(doc=170733,freq=1.0 = termFreq=1.0  
), product of:  
0.30741686 = queryWeight, product of:  
3.0631707 = idf(docFreq=728251, maxDocs=5731988)  
0.10035904 = queryNorm  
73.5161 = fieldWeight in 170733, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
3.0631707 = idf(docFreq=728251, maxDocs=5731988)  
24.0 = fieldNorm(doc=170733)  
129.25233 = weight(text:hotels in 170733) [PerFieldSimilarity],  
result of:  
129.25233 = score(doc=170733,freq=1.0 = termFreq=1.0  
), product of:  
0.73517686 = queryWeight, product of:  
7.3254676 = idf(docFreq=10260, maxDocs=5731988)  
0.10035904 = queryNorm  
175.81122 = fieldWeight in 170733, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
7.3254676 = idf(docFreq=10260, maxDocs=5731988)  
24.0 = fieldNorm(doc=170733)  
23.50164 = max of:  
23.50164 = weight(text:in^30.0 in 170733) [PerFieldSimilarity],  
result of:  
23.50164 = score(doc=170733,freq=1.0 = termFreq=1.0  
), product of:  
0.31348857 = queryWeight, product of:  
30.0 = boost  
3.1236706 = idf(docFreq=685498, maxDocs=5731988)  
0.0033453014 = queryNorm  
74.968094 = fieldWeight in 170733, product of:  
1.0 = tf(freq=1.0), with freq of:  
1.0 = termFreq=1.0  
3.1236706 = idf(docFreq=685498, maxDocs=5731988)  
24.0 = fieldNorm(doc=170733)  
1.0 = queryBoost

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/22d737da-5951-406a-863a-24eaf95e1382%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/22d737da-5951-406a-863a-24eaf95e1382%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 29, 2014, 4:10pm UTC](https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475/2 "2014-01-29T16:10:36Z")

</div>

Coder,

Your query is probably working properly. The explain does not show your  
custom score script logic but it should still be working as expected. You  
can verify it easily by changing your script logic. For example:

Try:

String script = "doc['po'].empty ? 1000 : doc['po'].value";

And you'll see that the actual score of the document is the value of your  
po field. (or 1000 if it doesn't exist).

--  
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/0e86cfc2-b19e-4662-86e6-aede06743d9f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0e86cfc2-b19e-4662-86e6-aede06743d9f%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 29, 2014, 4:17pm UTC](https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475/3 "2014-01-29T16:17:42Z")

</div>

But why am I getting exactly same score for two documents even though their  
po field hase different values. If I'm multiplying my score by this value  
the resultant value should be different for two, why am I getting same  
scores then ?

Also, here is my mapping looks like:

curl -XPUT '[http://localhost:9200/auto\_index/](http://localhost:9200/auto_index/)[http://localhost:9200/acqindex/](http://localhost:9200/acqindex/)'  
-d '{  
"settings" : {  
"index" : {  
"number\_of\_shards" : 1,  
"number\_of\_replicas" : 1,  
"analysis" : {  
"analyzer" : {  
"str\_search\_analyzer" : {  
"tokenizer" : "standard",  
"filter" : ["lowercase","asciifolding","  
suggestion\_shingle","edgengram"]  
},  
"str\_index\_analyzer" : {  
"tokenizer" : "standard",  
"filter" :  
["lowercase","asciifolding","suggestions\_shingle","edgengram"]  
}  
},  
"filter" : {  
"suggestions\_shingle": {  
"type": "shingle",  
"min\_shingle\_size": 2,  
"max\_shingle\_size": 5  
},  
"edgengram" : {  
"type" : "edgeNGram",  
"min\_gram" : 2,  
"max\_gram" : 30,  
"side" : "front"  
},  
"mynGram" : {  
"type" : "nGram",  
"min\_gram" : 2,  
"max\_gram" : 30  
}  
}  
},  
"similarity" : {  
"index": {  
"type":  
"org.elasticsearch.index.similarity.CustomSimilarityProvider"  
},  
"search": {  
"type":  
"org.elasticsearch.index.similarity.CustomSimilarityProvider"  
}  
}  
}  
}

curl -XPUT 'localhost:9200/auto\_index/autocomplete/\_mapping' -d '{  
"autocomplete":{  
"\_boost" : {  
"name" : "po",  
"null\_value" : 4.0  
},  
"properties": {  
"ad": {  
"type": "string",  
"search\_analyzer" : "str\_search\_analyzer",  
"index\_analyzer" : "str\_index\_analyzer",  
"omit\_norms": "true",  
"similarity": "index"  
},  
"category": {  
"type": "string",  
"include\_in\_all" : false  
},  
"cn": {  
"type": "string",  
"search\_analyzer" : "str\_search\_analyzer",  
"index\_analyzer" : "str\_index\_analyzer",  
"omit\_norms": "true",  
"similarity": "index"  
},  
"ctype": {  
"type": "string",  
"search\_analyzer" : "keyword",  
"index\_analyzer" : "keyword",  
"omit\_norms": "true",  
"similarity": "index"  
},  
"eid": {  
"type": "string",  
"include\_in\_all" : false  
},  
"st": {  
"type": "string",  
"search\_analyzer" : "str\_search\_analyzer",  
"index\_analyzer" : "str\_index\_analyzer",  
"omit\_norms": "true",  
"similarity": "index"  
},  
"co": {  
"type": "string",  
"include\_in\_all" : false  
},  
"st": {  
"type": "string",  
"search\_analyzer" : "str\_search\_analyzer",  
"index\_analyzer" : "str\_index\_analyzer",  
"omit\_norms": "true",  
"similarity": "index"  
},  
"co": {  
"type": "string",  
"search\_analyzer" : "str\_search\_analyzer",  
"index\_analyzer" : "str\_index\_analyzer",  
"omit\_norms": "true",  
"similarity": "index"  
},  
"po": {  
"type": "double",  
"boost": 4.0  
},  
"en":{  
"type": "boolean"  
},  
"\_oid":{  
"type": "long"  
},  
"text": {  
"type": "string",  
"search\_analyzer" : "str\_search\_analyzer",  
"index\_analyzer" : "str\_index\_analyzer",  
"omit\_norms": "true",  
"similarity": "index"  
},  
"url": {  
"type": "string"  
}  
}  
}  
}'

I hope I'm not doing anything wrong in my mapping for po field.

On Wed, Jan 29, 2014 at 9:40 PM, Binh Ly [binh@hibalo.com](mailto:binh@hibalo.com) wrote:

> Coder,
> 
> Your query is probably working properly. The explain does not show your  
> custom score script logic but it should still be working as expected. You  
> can verify it easily by changing your script logic. For example:
> 
> Try:
> 
> String script = "doc['po'].empty ? 1000 : doc['po'].value";
> 
> And you'll see that the actual score of the document is the value of your  
> po field. (or 1000 if it doesn't exist).
> 
> --  
> 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/0e86cfc2-b19e-4662-86e6-aede06743d9f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0e86cfc2-b19e-4662-86e6-aede06743d9f%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/CAAVTvp79evZr1c5vz8xVOc7yV4hh3bFiZjQtOduGS\_s2727reQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp79evZr1c5vz8xVOc7yV4hh3bFiZjQtOduGS_s2727reQ%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 29, 2014, 4:19pm UTC](https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475/4 "2014-01-29T16:19:12Z")

</div>

just an update: I'm using default similarity only. Ignore that  
customsimilarity line.

On Wed, Jan 29, 2014 at 9:47 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com) wrote:

> But why am I getting exactly same score for two documents even though  
> their po field hase different values. If I'm multiplying my score by this  
> value the resultant value should be different for two, why am I getting  
> same scores then ?
> 
> Also, here is my mapping looks like:
> 
> curl -XPUT '[http://localhost:9200/auto\_index/](http://localhost:9200/auto_index/)[http://localhost:9200/acqindex/](http://localhost:9200/acqindex/)'  
> -d '{  
> "settings" : {  
> "index" : {  
> "number\_of\_shards" : 1,  
> "number\_of\_replicas" : 1,  
> "analysis" : {  
> "analyzer" : {  
> "str\_search\_analyzer" : {  
> "tokenizer" : "standard",  
> "filter" : ["lowercase","asciifolding","  
> suggestion\_shingle","edgengram"]  
> },  
> "str\_index\_analyzer" : {  
> "tokenizer" : "standard",  
> "filter" :  
> ["lowercase","asciifolding","suggestions\_shingle","edgengram"]  
> }  
> },  
> "filter" : {  
> "suggestions\_shingle": {  
> "type": "shingle",  
> "min\_shingle\_size": 2,  
> "max\_shingle\_size": 5  
> },  
> "edgengram" : {  
> "type" : "edgeNGram",  
> "min\_gram" : 2,  
> "max\_gram" : 30,  
> "side" : "front"  
> },  
> "mynGram" : {  
> "type" : "nGram",  
> "min\_gram" : 2,  
> "max\_gram" : 30  
> }  
> }  
> },  
> "similarity" : {  
> "index": {  
> "type":  
> "org.elasticsearch.index.similarity.CustomSimilarityProvider"  
> },  
> "search": {  
> "type":  
> "org.elasticsearch.index.similarity.CustomSimilarityProvider"  
> }  
> }  
> }  
> }
> 
> curl -XPUT 'localhost:9200/auto\_index/autocomplete/\_mapping' -d '{  
> "autocomplete":{  
> "\_boost" : {  
> "name" : "po",  
> "null\_value" : 4.0  
> },  
> "properties": {  
> "ad": {  
> "type": "string",  
> "search\_analyzer" : "str\_search\_analyzer",  
> "index\_analyzer" : "str\_index\_analyzer",  
> "omit\_norms": "true",  
> "similarity": "index"  
> },  
> "category": {  
> "type": "string",  
> "include\_in\_all" : false  
> },  
> "cn": {  
> "type": "string",  
> "search\_analyzer" : "str\_search\_analyzer",  
> "index\_analyzer" : "str\_index\_analyzer",  
> "omit\_norms": "true",  
> "similarity": "index"  
> },  
> "ctype": {  
> "type": "string",  
> "search\_analyzer" : "keyword",  
> "index\_analyzer" : "keyword",  
> "omit\_norms": "true",  
> "similarity": "index"  
> },  
> "eid": {  
> "type": "string",  
> "include\_in\_all" : false  
> },  
> "st": {  
> "type": "string",  
> "search\_analyzer" : "str\_search\_analyzer",  
> "index\_analyzer" : "str\_index\_analyzer",  
> "omit\_norms": "true",  
> "similarity": "index"  
> },  
> "co": {  
> "type": "string",  
> "include\_in\_all" : false  
> },  
> "st": {  
> "type": "string",  
> "search\_analyzer" : "str\_search\_analyzer",  
> "index\_analyzer" : "str\_index\_analyzer",  
> "omit\_norms": "true",  
> "similarity": "index"  
> },  
> "co": {  
> "type": "string",  
> "search\_analyzer" : "str\_search\_analyzer",  
> "index\_analyzer" : "str\_index\_analyzer",  
> "omit\_norms": "true",  
> "similarity": "index"  
> },  
> "po": {  
> "type": "double",  
> "boost": 4.0  
> },  
> "en":{  
> "type": "boolean"  
> },  
> "\_oid":{  
> "type": "long"  
> },  
> "text": {  
> "type": "string",  
> "search\_analyzer" : "str\_search\_analyzer",  
> "index\_analyzer" : "str\_index\_analyzer",  
> "omit\_norms": "true",  
> "similarity": "index"  
> },  
> "url": {  
> "type": "string"  
> }  
> }  
> }  
> }'
> 
> I hope I'm not doing anything wrong in my mapping for po field.
> 
> On Wed, Jan 29, 2014 at 9:40 PM, Binh Ly [binh@hibalo.com](mailto:binh@hibalo.com) wrote:
> 
> > Coder,
> > 
> > Your query is probably working properly. The explain does not show your  
> > custom score script logic but it should still be working as expected. You  
> > can verify it easily by changing your script logic. For example:
> > 
> > Try:
> > 
> > String script = "doc['po'].empty ? 1000 : doc['po'].value";
> > 
> > And you'll see that the actual score of the document is the value of your  
> > po field. (or 1000 if it doesn't exist).
> > 
> > --  
> > 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/0e86cfc2-b19e-4662-86e6-aede06743d9f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0e86cfc2-b19e-4662-86e6-aede06743d9f%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/CAAVTvp5u2BpUcqs8HZvBYA3zUu8mLiuvfZ%3DXeySffz-yoOF\_XA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp5u2BpUcqs8HZvBYA3zUu8mLiuvfZ%3DXeySffz-yoOF_XA%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 29, 2014, 5:04pm UTC](https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475/5 "2014-01-29T17:04:07Z")

</div>

Just to clarify, can you post the scores of the 2 documents in question:

1. script = "\_score"

2. script = "doc['po'].value"

Just curious to see the actual values.

--  
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/8df89eed-7b61-4227-a601-21a81e46b20a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8df89eed-7b61-4227-a601-21a81e46b20a%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, 8:17am UTC](https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475/6 "2014-01-30T08:17:36Z")

</div>

Binh,

I'm not able to access po field. It's giving me error:

Caused by: [Error: could not access: value; in class:  
org.elasticsearch.index.fielddata.ScriptDocValues$Empty]  
[Near : {... doc['po'].value ....}]

I think that is the reason why my score is always same. Everytime, it is  
taking it as empty though all my docs contains this field. I have also  
added it in my mapping. Can you please tell me why it is behaving like this  
?

On Wed, Jan 29, 2014 at 10:34 PM, Binh Ly [binh@hibalo.com](mailto:binh@hibalo.com) wrote:

> Just to clarify, can you post the scores of the 2 documents in question:
> 
> 1. script = "\_score"
> 
> 2. script = "doc['po'].value"
> 
> Just curious to see the actual values.
> 
> --  
> 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/8df89eed-7b61-4227-a601-21a81e46b20a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8df89eed-7b61-4227-a601-21a81e46b20a%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/CAAVTvp4VyCD8\_QHRjyCFOBxSxoVPVHt\_%2BcJxOcmOQ%3DhBmSuy%2Bw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp4VyCD8_QHRjyCFOBxSxoVPVHt_%2BcJxOcmOQ%3DhBmSuy%2Bw%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:02pm UTC](https://discuss.elastic.co/t/need-some-help-with-custom-score-query/15475/7 "2014-01-30T13:02:18Z")

</div>

Binh,

Can you take a look at this also.

Thanks

On Thu, Jan 30, 2014 at 1:47 PM, Mukul Gupta [mukulnitkkr@gmail.com](mailto:mukulnitkkr@gmail.com) wrote:

> Binh,
> 
> I'm not able to access po field. It's giving me error:
> 
> Caused by: [Error: could not access: value; in class:  
> org.elasticsearch.index.fielddata.ScriptDocValues$Empty]  
> [Near : {... doc['po'].value ....}]
> 
> I think that is the reason why my score is always same. Everytime, it is  
> taking it as empty though all my docs contains this field. I have also  
> added it in my mapping. Can you please tell me why it is behaving like this  
> ?
> 
> On Wed, Jan 29, 2014 at 10:34 PM, Binh Ly [binh@hibalo.com](mailto:binh@hibalo.com) wrote:
> 
> > Just to clarify, can you post the scores of the 2 documents in question:
> > 
> > 1. script = "\_score"
> > 
> > 2. script = "doc['po'].value"
> > 
> > Just curious to see the actual values.
> > 
> > --  
> > 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/8df89eed-7b61-4227-a601-21a81e46b20a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8df89eed-7b61-4227-a601-21a81e46b20a%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/CAAVTvp51u1Na\_-SSnXmSQn7tPZV4V-VMrxDSf6LoLa%3Djjwb9cQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAVTvp51u1Na_-SSnXmSQn7tPZV4V-VMrxDSf6LoLa%3Djjwb9cQ%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/need-some-help-with-custom-score-query/15475/8 "2017-07-06T01:53:56Z")

</div>


