# Score varying for same values

**URL:** <https://discuss.elastic.co/t/score-varying-for-same-values/4542>\
**Category:** Elasticsearch\
**Created:** [June 3, 2011, 6:14am UTC](https://discuss.elastic.co/t/score-varying-for-same-values/4542 "2011-06-03T06:14:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![senthil\_prabhu](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@senthil\_prabhu](https://discuss.elastic.co/u/senthil_prabhu)\
**Post date:** [June 3, 2011, 6:14am UTC](https://discuss.elastic.co/t/score-varying-for-same-values/4542/1 "2011-06-03T06:14:56Z")

</div>

Here i have created a gist example.

I have created a indices with a single field named "message". In that  
indices, I have 10 documents with same message string, while searching  
on this indices i am getting different score values for resulting  
documents.

Gist Example Here......

curl -XPUT '[http://192.168.0.141:9200/dbtest123](http://192.168.0.141:9200/dbtest123)'

curl -XPUT '[http://192.168.0.141:9200/dbtest123/meta/\_mapping](http://192.168.0.141:9200/dbtest123/meta/_mapping)' -d  
'{"datatable" : { "properties" : { "message" : {"type" : "string",  
"store" : "yes"} } } }'

curl -XPUT '[http://192.168.0.141:9200/dbtest123/meta/1](http://192.168.0.141:9200/dbtest123/meta/1)' -d  
'{"message" :"trying out Elastic Search It takes the snapshot while  
working on group of documents, Based on the snapshot, it will do  
update process or other task"}'  
curl -XPUT '[http://192.168.0.141:9200/dbtest123/meta/2](http://192.168.0.141:9200/dbtest123/meta/2)' -d  
'{"message" : "trying out Elastic Search It takes the snapshot while  
working on group of documents, Based on the snapshot, it will do  
update process or other task"}'  
curl -XPUT '[http://192.168.0.141:9200/dbtest123/meta/3](http://192.168.0.141:9200/dbtest123/meta/3)' -d  
'{"message" :"trying out Elastic Search It takes the snapshot while  
working on group of documents, Based on the snapshot, it will do  
update process or other task" }'  
....  
....  
....  
up to 10 documents....

curl -XGET '[http://192.168.0.141:9200/dbtest123/meta/\_search](http://192.168.0.141:9200/dbtest123/meta/_search)' -d  
'{"query":{"term" : { "message" : "search" }}}'

{"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":  
5,"failed":0},"hits":{"total":10,"max\_score":0.15581955,"hits":  
[{"\_index":"db123","\_type":"meta","\_id":"3","\_score":0.15581955,  
"\_source" : { "message" : "trying out Elastic Search It takes the  
snapshot while working on group of documents, Based on the snapshot,  
it will do update process or other task"}},  
{"\_index":"db123","\_type":"meta","\_id":"8","\_score":0.15581955,  
"\_source" : { "message" : "trying out Elastic Search It takes the  
snapshot while working on group of documents, Based on the snapshot,  
it will do update process or other task"}},  
{"\_index":"db123","\_type":"meta","\_id":"10","\_score":0.15581955,  
"\_source" : { "message" : "trying out Elastic Search It takes the  
snapshot while working on group of documents, Based on the snapshot,  
it will do update process or other task"}},{"\_index":"db123","\_type":"  
meta","\_id":"4","\_score":0.13005449, "\_source" : { "message" : "trying  
out Elastic Search It takes the snapshot while working on group of  
documents, Based on the snapshot, it will do update process or other  
task"}},{"\_index":"db123","\_type":"meta","\_id":"9","\_score":  
0.13005449, "\_source" : { "message" : "trying out Elastic Search It  
takes the snapshot while working on group of documents, Based on the  
snapshot, it will do update process or other task"}},  
{"\_index":"db123","\_type":"meta","\_id":"1","\_score":0.13005449,  
"\_source" : { "message" : "trying out Elastic Search It takes the  
snapshot while working on group of documents, Based on the snapshot,  
it will do update process or other task"}},  
{"\_index":"db123","\_type":"meta","\_id":"6","\_score":0.13005449,  
"\_source" : { "message" : "trying out Elastic Search It takes the  
snapshot while working on group of documents, Based on the snapshot,  
it will do update process or other task"}},  
{"\_index":"db123","\_type":"meta","\_id":"2","\_score":0.13005449,  
"\_source" : { "message" : "trying out Elastic Search It takes the  
snapshot while working on group of documents, Based on the snapshot,  
it will do update process or other task"}},  
{"\_index":"db123","\_type":"meta","\_id":"7","\_score":0.13005449,  
"\_source" : { "message" : "trying out Elastic Search It takes the  
snapshot while working on group of documents, Based on the snapshot,  
it will do update process or other task"}},  
{"\_index":"db123","\_type":"meta","\_id":"5","\_score":0.067124054,  
"\_source" : { "message" : "trying out Elastic Search It takes the  
snapshot while working on group of documents, Based on the snapshot,  
it will do update process or other task"}}]}}.

Questions:

1. Why does the score varying for same content?

2. How does the score value calculated in Elastic Search...?

3. If i have a Boolean query for multiple field, Can we mention a  
specific field for score calculation for full query....?

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 3, 2011, 9:00am UTC](https://discuss.elastic.co/t/score-varying-for-same-values/4542/2 "2011-06-03T09:00:32Z")

</div>

Hiya

> I have created a indices with a single field named "message". In that  
> indices, I have 10 documents with same message string, while searching  
> on this indices i am getting different score values for resulting  
> documents.

Your docs are stored in different shards, so each shard has a local idea  
of how important each term is - it only knows about docs that live in  
its own shard.

This is likely to be approximately right, but in certain cases (like  
your example) will be slightly inaccurate.

If you add the parameter search\_type=dfs\_query\_then\_fetch this will  
retrieve the scores for the relevant terms from all shards first,  
calculate the real global value, then score correctly. However, this  
obviously doesn't perform quite as well as the default  
"query\_then\_fetch".

Try:

curl -XGET '[http://localhost:9200/dbtest123/meta/\_search?pretty=1&search\_type=dfs\_query\_then\_fetch](http://localhost:9200/dbtest123/meta/_search?pretty=1&search_type=dfs_query_then_fetch)' -d '  
{"query":{"term" : { "message" : "search" }}}'

clint

---

<div class="post-metadata">

**Author:** ![senthil\_prabhu](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@senthil\_prabhu](https://discuss.elastic.co/u/senthil_prabhu)\
**Post date:** [June 3, 2011, 1:15pm UTC](https://discuss.elastic.co/t/score-varying-for-same-values/4542/3 "2011-06-03T13:15:58Z")

</div>

thanks for your response....

On Jun 3, 2:00 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> Hiya
> 
> > I have created a indices with a single field named "message". In that  
> > indices, I have 10 documents with same message string, while searching  
> > on this indices i am getting different score values for resulting  
> > documents.
> 
> Your docs are stored in different shards, so each shard has a local idea  
> of how important each term is - it only knows about docs that live in  
> its own shard.
> 
> This is likely to be approximately right, but in certain cases (like  
> your example) will be slightly inaccurate.
> 
> If you add the parameter search\_type=dfs\_query\_then\_fetch this will  
> retrieve the scores for the relevant terms from all shards first,  
> calculate the real global value, then score correctly. However, this  
> obviously doesn't perform quite as well as the default  
> "query\_then\_fetch".
> 
> Try:
> 
> curl -XGET '[http://localhost:9200/dbtest123/meta/\_search?pretty=1&search\_type=dfs](http://localhost:9200/dbtest123/meta/_search?pretty=1&search_type=dfs)...-d '  
> {"query":{"term" : { "message" : "search" }}}'
> 
> clint

---

<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/score-varying-for-same-values/4542/4 "2017-07-06T04:04:43Z")

</div>


