Hello,
I'm struggling a bit to write a query that would query fields on a parent
document and the fields on a child document.
first thought, my mapping:
I have documents of type 'resource' (these are the parent docs)
which have a couple of fields, the ones I'll be querying are called
'q_high' and 'q_low'.
I also have documents of type 'message' (the child documents) which have
the same q_high and q_low fields
We've modelled it this way as all top level resources can have messages
associated with them.
When we search for resources, we'd also like to search trough all the
messages that are associated with a resource.
Now I want to write a query where:
- the q_high or q_low field match a string (chicken in the example below)
- OR the q_high/q_low field match the same string.
When a child document matches, I only need the parent document.
So far, I have the following Bool query:
{
"bool": {
"should": [
{
"multi_match": {
"fields": [
"q_high^2.0",
"q_low^0.75"
],
"query": "chicken"
}
},
{
"has_child": {
"type": "message",
"query": {
"multi_match": {
"fields": [
"q_high^2.0",
"q_low^0.75"
],
"query": "chicken"
}
}
}
}
]
}
}
This works, but the more content I put into the system the lower the score
of child documents get.
When there are only 2 documents in the system (the parent and child) the
child gets a score of about 0.6.
When there are about 660 documents in the system, the score plumets to 0.02
Is there a better way to do queries like this?
Kind regards,
Simon Gaeremynck
--
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.