# Why is queryWeight included for some result scores, but not others, in the same query?

**URL:** https://discuss.elastic.co/t/why-is-queryweight-included-for-some-result-scores-but-not-others-in-the-same-query/15424
**Category:** Elasticsearch
**Created:** [January 26, 2014, 11:10pm UTC](https://discuss.elastic.co/t/why-is-queryweight-included-for-some-result-scores-but-not-others-in-the-same-query/15424 "2014-01-26T23:10:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tyler\_Mandry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tyler_mandry/32/1835_2.png) [@Tyler\_Mandry](https://discuss.elastic.co/u/Tyler_Mandry)
#### Post date: [January 26, 2014, 11:10pm UTC](https://discuss.elastic.co/t/why-is-queryweight-included-for-some-result-scores-but-not-others-in-the-same-query/15424/1 "2014-01-26T23:10:28Z")

</div>

I'm executing a query\_string query with one term on multiple fields, \_all  
and tags.name, and trying to understand the scoring. Query:  
{"query":{"query\_string":{"query":"animal","fields":["\_all","tags.name"]}}}.  
Here are the documents returned by the query:

- _Document 1_ has an exact match on tags.name, but not on \_all.
- _Document 8_ has an exact match on both tags.name and on \_all.

Document 8 should win, and it does, but I'm confused by how the scoring  
works out. It seems like Document 1 is getting penalized by having its  
tags.name score multiplied by the IDF twice, whereas Document 8's tags.name score  
is only multiplied by the IDF once. In short:

- They both have a component weight(tags.name:animal in 0)  
[PerFieldSimilarity].
- In Document 1, we have weight = score = queryWeight x fieldWeight.
- In Document 8, we have weight = fieldWeight!

Since queryWeight contains idf, this results in Document 1 getting  
penalized by its idf twice.

Can anyone make sense of this?

I posted this on Stackoverflow[http://stackoverflow.com/questions/21213947/why-is-queryweight-included-for-some-result-scores-but-not-others](http://stackoverflow.com/questions/21213947/why-is-queryweight-included-for-some-result-scores-but-not-others)a week ago; the question has some additional information attached to it.

--  
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/e9bbf46a-b375-45a0-bdd4-3510416bbb03%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e9bbf46a-b375-45a0-bdd4-3510416bbb03%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: ![keyhook](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@keyhook](https://discuss.elastic.co/u/keyhook)
#### Post date: [April 7, 2016, 7:23pm UTC](https://discuss.elastic.co/t/why-is-queryweight-included-for-some-result-scores-but-not-others-in-the-same-query/15424/2 "2016-04-07T19:23:58Z")

</div>

Hi all,

I'm using Elasticsearch 1.7.0 & also suffering from this same problem. I googled it day by day but still find no reasonable answer except the vague clue that it relates to the sharding effect. But how? Could anyone please help me?

Best regards,

---

<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 5, 2017, 11:01pm UTC](https://discuss.elastic.co/t/why-is-queryweight-included-for-some-result-scores-but-not-others-in-the-same-query/15424/3 "2017-07-05T23:01:23Z")

</div>


