# Different score for exact same keyword

**URL:** <https://discuss.elastic.co/t/different-score-for-exact-same-keyword/15844>\
**Category:** Elasticsearch\
**Created:** [February 17, 2014, 11:00am UTC](https://discuss.elastic.co/t/different-score-for-exact-same-keyword/15844 "2014-02-17T11:00:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vallabh](https://avatars.discourse-cdn.com/v4/letter/v/e8c25b/32.png) [@vallabh](https://discuss.elastic.co/u/vallabh)\
**Post date:** [February 17, 2014, 11:00am UTC](https://discuss.elastic.co/t/different-score-for-exact-same-keyword/15844/1 "2014-02-17T11:00:47Z")

</div>

Dear Friends,

I am using phonetic analysis in elasticsearch to search best results.

When i search keyword lets say "McDonald" elastic search returns many  
listings with "McDonald's" but some of these have differrent scores.

I am manipulating results based on score and due to this difference its  
affecting my functionality.

All returned listings with "McDonald" have same case and are exact.

For Ex:  
_Name score_  
McDonald's _5.8059134_  
McDonald's 5.8059134  
McDonald's 5.8059134  
McDonald's _5.7834973_  
McDonald's 5.7834973  
McDonald's _5.4078074_

As shown in example above there are 3 different scores which are  
highlighted.

Any help is very much appreciated.

Regards,  
Vallabh

--  
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/10e3e24b-06cc-4e46-acf8-b6c46a549cc2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/10e3e24b-06cc-4e46-acf8-b6c46a549cc2%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:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [February 17, 2014, 11:20am UTC](https://discuss.elastic.co/t/different-score-for-exact-same-keyword/15844/2 "2014-02-17T11:20:51Z")

</div>

your query runs in parallel on multiple shards and score you seeing is  
computed independently on every shard  
the default similarity is tf/idf based, which means it is using terms  
frequency across all documents (so your score on the shard will depend on  
data on this shard)  
for score to be this same, every shard will have to have more or less this  
same documents

you can change search\_type to compute score when combining results from  
shards (slower):

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

also check this out (to learn more about similarity algorithms used by  
elasticsearch):

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

because you are searching for user names, it is possible that you could  
wrap your query in constant (or function) score query and settle for less  
granular scoring:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Cheers,  
Karol Gwaj

On Monday, February 17, 2014 11:00:47 AM UTC, Vallabh Bothre wrote:

> Dear Friends,
> 
> I am using phonetic analysis in elasticsearch to search best results.
> 
> When i search keyword lets say "McDonald" Elasticsearch returns many  
> listings with "McDonald's" but some of these have differrent scores.
> 
> I am manipulating results based on score and due to this difference its  
> affecting my functionality.
> 
> All returned listings with "McDonald" have same case and are exact.
> 
> For Ex:  
> _Name score_  
> McDonald's _5.8059134_  
> McDonald's 5.8059134  
> McDonald's 5.8059134  
> McDonald's _5.7834973_  
> McDonald's 5.7834973  
> McDonald's _5.4078074_
> 
> As shown in example above there are 3 different scores which are  
> highlighted.
> 
> Any help is very much appreciated.
> 
> Regards,  
> Vallabh

--  
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/58f4e7c8-c785-4e5b-96d3-33148c780055%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/58f4e7c8-c785-4e5b-96d3-33148c780055%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:** ![vallabh](https://avatars.discourse-cdn.com/v4/letter/v/e8c25b/32.png) [@vallabh](https://discuss.elastic.co/u/vallabh)\
**Post date:** [February 17, 2014, 3:23pm UTC](https://discuss.elastic.co/t/different-score-for-exact-same-keyword/15844/3 "2014-02-17T15:23:27Z")

</div>

Thanks Karol for replying,

As per your suggestion i used search type which execute the query on all  
relevant shards and return the results.  
"search\_type" =\> "query\_then\_fetch"

But still i am getting different score for same keyword.

On Monday, February 17, 2014 4:50:51 PM UTC+5:30, Karol Gwaj wrote:

> your query runs in parallel on multiple shards and score you seeing is  
> computed independently on every shard  
> the default similarity is tf/idf based, which means it is using terms  
> frequency across all documents (so your score on the shard will depend on  
> data on this shard)  
> for score to be this same, every shard will have to have more or less this  
> same documents
> 
> you can change search\_type to compute score when combining results from  
> shards (slower):
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-search-type.html)
> 
> also check this out (to learn more about similarity algorithms used by  
> elasticsearch):
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-similarity.html)
> 
> because you are searching for user names, it is possible that you could  
> wrap your query in constant (or function) score query and settle for less  
> granular scoring:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)
> 
> Cheers,  
> Karol Gwaj
> 
> On Monday, February 17, 2014 11:00:47 AM UTC, Vallabh Bothre wrote:
> 
> > Dear Friends,
> > 
> > I am using phonetic analysis in elasticsearch to search best results.
> > 
> > When i search keyword lets say "McDonald" Elasticsearch returns many  
> > listings with "McDonald's" but some of these have differrent scores.
> > 
> > I am manipulating results based on score and due to this difference its  
> > affecting my functionality.
> > 
> > All returned listings with "McDonald" have same case and are exact.
> > 
> > For Ex:  
> > _Name score_  
> > McDonald's _5.8059134_  
> > McDonald's 5.8059134  
> > McDonald's 5.8059134  
> > McDonald's _5.7834973_  
> > McDonald's 5.7834973  
> > McDonald's _5.4078074_
> > 
> > As shown in example above there are 3 different scores which are  
> > highlighted.
> > 
> > Any help is very much appreciated.
> > 
> > Regards,  
> > Vallabh

--  
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/43e289b6-c8c2-48db-ace2-18c4b330d2eb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43e289b6-c8c2-48db-ace2-18c4b330d2eb%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:** ![Isabel\_Drost\_Fromm](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@Isabel\_Drost\_Fromm](https://discuss.elastic.co/u/Isabel_Drost_Fromm)\
**Post date:** [February 17, 2014, 3:47pm UTC](https://discuss.elastic.co/t/different-score-for-exact-same-keyword/15844/4 "2014-02-17T15:47:02Z")

</div>

On Mon, Feb 17, 2014 at 4:23 PM, Vallabh Bothre [vallabh.bothre@gmail.com](mailto:vallabh.bothre@gmail.com)wrote:

> As per your suggestion i used search type which execute the query on all  
> relevant shards and return the results.  
> "search\_type" =\> "query\_then\_fetch"

As per

> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)
> 
> > reference/current/search-request-search-type.html

this is the default search type used even when not explicitly specifying a  
search type.

As per

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

> > modules-similarity.html

Elasticsearch uses TF/IDF as default similarity. For more information on  
how TF/IDF is computed see also the Lucene documentation:

[http://lucene.apache.org/core/4\_0\_0/core/org/apache/lucene/search/similarities/TFIDFSimilarity.html](http://lucene.apache.org/core/4_0_0/core/org/apache/lucene/search/similarities/TFIDFSimilarity.html)

The different scores you are seeing is probably caused by different IDF  
scores on each shard. If you really need the exact IDF values on each shard  
you should checkout dfs\_query\_[and/then]\_fetch.

Isabel

--  
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/CAFSgB-Bt6VN4oxEHy86YrS7NsvxDwEj9ids58PT-FEOd4WJZgw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFSgB-Bt6VN4oxEHy86YrS7NsvxDwEj9ids58PT-FEOd4WJZgw%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:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [February 20, 2014, 11:02am UTC](https://discuss.elastic.co/t/different-score-for-exact-same-keyword/15844/5 "2014-02-20T11:02:12Z")

</div>

yep, as Isabel mentioned, you should use _dfs\_query\_then\_fetch_ search type  
(it is slower doo)

On Monday, February 17, 2014 3:23:27 PM UTC, Vallabh Bothre wrote:

> Thanks Karol for replying,
> 
> As per your suggestion i used search type which execute the query on all  
> relevant shards and return the results.  
> "search\_type" =\> "query\_then\_fetch"
> 
> But still i am getting different score for same keyword.
> 
> On Monday, February 17, 2014 4:50:51 PM UTC+5:30, Karol Gwaj wrote:
> 
> > your query runs in parallel on multiple shards and score you seeing is  
> > computed independently on every shard  
> > the default similarity is tf/idf based, which means it is using terms  
> > frequency across all documents (so your score on the shard will depend on  
> > data on this shard)  
> > for score to be this same, every shard will have to have more or less  
> > this same documents
> > 
> > you can change search\_type to compute score when combining results from  
> > shards (slower):
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-search-type.html)
> > 
> > also check this out (to learn more about similarity algorithms used by  
> > elasticsearch):
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-similarity.html)
> > 
> > because you are searching for user names, it is possible that you could  
> > wrap your query in constant (or function) score query and settle for less  
> > granular scoring:
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html)
> > 
> > Cheers,  
> > Karol Gwaj
> > 
> > On Monday, February 17, 2014 11:00:47 AM UTC, Vallabh Bothre wrote:
> > 
> > > Dear Friends,
> > > 
> > > I am using phonetic analysis in elasticsearch to search best results.
> > > 
> > > When i search keyword lets say "McDonald" Elasticsearch returns many  
> > > listings with "McDonald's" but some of these have differrent scores.
> > > 
> > > I am manipulating results based on score and due to this difference its  
> > > affecting my functionality.
> > > 
> > > All returned listings with "McDonald" have same case and are exact.
> > > 
> > > For Ex:  
> > > _Name score_  
> > > McDonald's _5.8059134_  
> > > McDonald's 5.8059134  
> > > McDonald's 5.8059134  
> > > McDonald's _5.7834973_  
> > > McDonald's 5.7834973  
> > > McDonald's _5.4078074_
> > > 
> > > As shown in example above there are 3 different scores which are  
> > > highlighted.
> > > 
> > > Any help is very much appreciated.
> > > 
> > > Regards,  
> > > Vallabh

--  
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/9680df2f-1301-4637-88d0-7c56c15a25e1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9680df2f-1301-4637-88d0-7c56c15a25e1%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:** ![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:48am UTC](https://discuss.elastic.co/t/different-score-for-exact-same-keyword/15844/6 "2017-07-06T01:48:46Z")

</div>


