I was glad to see the "score_type" feature added in 0.20.2 which allows
the parents scoring to be transferred to the child.
http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query.html
But I think there is a bug when I use it.
I have not yet reduced it to a simple example, but I have done the
following.
- checked all children have a routing value equal to their parents ID.
- checked all parents have a routing value equals to their own ID.
- run a particular query with and without the "score_type" : "score" in
the "has_parent" query.
"score_type": "none" (or without the new "score_type" field)
I get all the documents I expect.
"score_type": "score"
SOMETIMES I GET 3 DOCUMENTS SOMETIMES I GET 4 IN THE RESULT.
I just have to try it in the head plugin and hit submit and value
changes between 3 and 4, but not consistently.
There are no node failures. I only have two shards.
Here is the most reduced query I could come up with that is like what
I'd like to do which is find children that have parents. Where some of
the scoring comes from the parents.
Of course in my real query the criteria for the parents is more complex
than "match_all".
curl 'http://localhost:9200/myindex/MyChildType/_search' - d '
{
"from": 0,
"timeout": 4000,
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"has_parent": {
"query": {
"match_all": {}
},
"parent_type": "MjDocument",
"score_type": "none" <-- change this to
"score_type": "score" and you get fewer results expected 9, sometimes 3
sometimes 4.
}
}
],
"boost": 1000
}
},
"filter": {
"prefix": {
"Path.NALocation": "Bugs\Phrase Boosting\Subphrase\"
}
}
}
}
}'
I know that prefix queries are slow, I just use it here to find exactly
the set of files I was testing with. The filter works.
Am I doing the "has_parent" wrong or there something else wrong here?
Point 2:
The doc for this new feature needs some work.
"The supported score types are |score| or |none|. The default is |none|
and yields the same behavior as in previous versions. If the score type
is set to another value than |none|, the scores of all the matching
parent documents are aggregated into the associated child documents. "
http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query.html
- "same .. as in previous" Now how is a new user (or someone reviewing
existing behavior) supposed to know what the old behavior is or was? - " the scores of all the matching parent documents are aggregated into
the associated child documents" It looks like someone copied this from
the same sentence in the "has_child".
I assume no parents score_s_ are aggregated together only that "... the
score of each matching parent document is aggregated into the score
for each of its child documents."
Document_s_ to Document_s_ doesn't actually provide any useful
documentation about what goes where and could be replaced with "some
scores are moved about"
If someone can confirm 1, 2 and provide a description of expected "old"
behavior (for "none"), I'll even submit a pull request for the changes
to this page.
Also if someone can think of a different or more efficient way to score
filtered children based at least partially on the score of the parents,
please suggest.
-Paul
--
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.
For more options, visit https://groups.google.com/groups/opt_out.