# Has\_parent + compound query scoring problem

**URL:** <https://discuss.elastic.co/t/has-parent-compound-query-scoring-problem/22204>\
**Category:** Elasticsearch\
**Created:** [February 17, 2015, 9:28am UTC](https://discuss.elastic.co/t/has-parent-compound-query-scoring-problem/22204 "2015-02-17T09:28:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Csaba\_Dezsenyi](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@Csaba\_Dezsenyi](https://discuss.elastic.co/u/Csaba_Dezsenyi)\
**Post date:** [February 17, 2015, 9:28am UTC](https://discuss.elastic.co/t/has-parent-compound-query-scoring-problem/22204/1 "2015-02-17T09:28:59Z")

</div>

Hi All,

I found a weird scoring behavior of elasticsearch when using has\_parent  
query together with normal query.

I have two document types in the index:

- _document_: Normal document
- _review_: Reviews that are child elements of the documents

I would like to create a compound query that searches for both types. The  
features of the query basically:

- Search in properties of document (title, author, abstract, ...)
- Search in properties of review (reviewer, review text, ...)
- Search also in parent properties of review , i.e. the properties of  
the parent document joined by has\_parent query (title, abstract, ...)
- Have multiple query parts connected by bool or dis\_max, e.g. basic  
query\_string query and additional proximity boost part (phrase match +  
slop) or fuzzy part

I would like to have a harmonized scoring behavior, i.e. if I search for a  
term in a document title, then I would like to receive the matching  
document and all of its reviews with the same score values.  
This seemed to work when I started, however, after a while it became weird,  
and I got many inexpiable scores.  
Unfortunately, we cannot use the nice explain="true" feature for the  
has\_parent query ("not implemented..."), so it is limited for me to debug  
the problem.

I've created a really small curl-based example on gist:

> <https://gist.github.com/dezsenyi/6a73e953ea6c78bf7774>

The last two queries represents the main problem:

- _Test query 1_: Two query\_string query combined with dis\_max, one is  
for documents, the other is for reviews and thus has\_parent is applied. It  
is working fine, the document and the review have the same scores (0,375).
- _Test query 2_: The very same query above applied twice, combined with  
a bool query. I expected to have again same scores, but the result scores  
are different for the document and for the review (???).

After checking the scores, it seems to me that the problem relates to the  
_query\_norm_ value that is maybe different at the has\_parent parts.  
For "Test query 1" the result score is 0.375 for both (document, review).  
For "Test query 2" the matched review (by has\_parent) got exactly 2 x 0.375  
= 0.75, while the document score is less that - I guess - comes mainly from  
the less query\_norm value.  
However, I could not confirm it, since I cannot see explain for has\_parent  
parts...

Can anybody help me?  
Thank you in advance!

Regards,  
Csaba D.

--  
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/b9da5514-5c7f-4314-8f40-f3dad8764f6a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9da5514-5c7f-4314-8f40-f3dad8764f6a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:32am UTC](https://discuss.elastic.co/t/has-parent-compound-query-scoring-problem/22204/2 "2017-07-06T00:32:13Z")

</div>


