Custom_score query within has_child query

I want to use a custom_score query within has_child query, so that I can
control the score of the child documents. However when I reference a child
document field in has_child custom_score query, ES is trying to map the
field to parent document and is throwing error.

Can anyone please throw some light on this issue and any workarounds?

Thanks & Regards,
Aditya.

--
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.

Can someone please help me with this? It is quite important for one of our
product use cases.

Thanks & Regards,
Aditya.

On Wednesday, July 3, 2013 1:31:53 PM UTC+5:30, aditya.p...@wagglebee.net
wrote:

I want to use a custom_score query within has_child query, so that I can
control the score of the child documents. However when I reference a child
document field in has_child custom_score query, ES is trying to map the
field to parent document and is throwing error.

Can anyone please throw some light on this issue and any workarounds?

Thanks & Regards,
Aditya.

--
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.

Here is a more detailed version of issue I'm facing...

custom_score query within has_child query does not recognize child document
fields within the score script.

I have two document types, "Forums" and "ForumStats". Forums is a parent
type and ForumStats is a child type. I had set the mapping correctly.

When I issue query like the one below on forums type, ES complains that the
field "avgPostsPerMinute" is not found in "Forums" type, which I feel is
wrong as the script is supposed to look at child document fields.

{
"size": 20,
"sort": {
"_score": "desc"
},
"query": {
"has_child": {
"type": "forumstats",
"score_type": "sum",
"query": {
"custom_score": {
"script": "doc['avgPostsPerMin'].value",
"query": {
"match_all": {}
}
}
}
}
}
}

If I set the script to a value that doe snot refer to child document type,
then the query runs and I get a score for the parent document correctly.

Please review this and let me know if this is by design or a bug. If it is
by design, it looks odd as the custom score query is running on child
documents and I would expect ES to recognize the child document fields
within the script property.

Thanks & Regards,
Aditya.

On Wednesday, July 3, 2013 2:53:36 PM UTC+5:30, aditya.p...@wagglebee.net
wrote:

Can someone please help me with this? It is quite important for one of our
product use cases.

Thanks & Regards,
Aditya.

On Wednesday, July 3, 2013 1:31:53 PM UTC+5:30, aditya.p...@wagglebee.netwrote:

I want to use a custom_score query within has_child query, so that I can
control the score of the child documents. However when I reference a child
document field in has_child custom_score query, ES is trying to map the
field to parent document and is throwing error.

Can anyone please throw some light on this issue and any workarounds?

Thanks & Regards,
Aditya.

--
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.

Finally I could resolve the issue myself.

For anyone looking for a solution for similar issue, here is what I did to
solve.

In the query mentioned in this posts, specify the child document field with
child document type prefix. So the below query will work as expected.

Note: "avgPostsPerMin" is a field in child document type, "forumstats", and
the below query is run on the parent document type, "forums".

{
"size": 20,
"sort": {
"_score": "desc"
},
"query": {
"has_child": {
"type": "forumstats",
"score_type": "sum",
"query": {
"custom_score": {
"script": "doc['forumstats.avgPostsPerMin'].value",
"query": {
"match_all": {}
}
}
}
}
}
}

On Wednesday, July 3, 2013 1:31:53 PM UTC+5:30, aditya.p...@wagglebee.net
wrote:

I want to use a custom_score query within has_child query, so that I can
control the score of the child documents. However when I reference a child
document field in has_child custom_score query, ES is trying to map the
field to parent document and is throwing error.

Can anyone please throw some light on this issue and any workarounds?

Thanks & Regards,
Aditya.

--
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.