Consider an index having the types 'primary' and 'meta', the latter being a
child of the former:
curl -XPUT 'http://localhost:9200/idx/meta/_mapping' -d '
{
"meta" : {
"_parent": {"type":"primary"},
"properties":{
"rating" : {"type":"integer", "store":true},
}
}
}
'
It is a one to one mapping, so each primary document will have exactly one
corresponding meta document. This is designed so as to decouple updates to
the meta, which can be relatively much more frequent compared to primary.
Now, the area of interest for search here is the 'primary' type. So queries
will be run on that. However, irrespective of the query run, I want to be
able to boost each matching document based on it's 'meta' child's 'rating'
field. E.g. if I a query matches two documents, pri1 and pri2, and the
'rating' field for pri1's child 'meta1' is 5 and that of pri2's child
'meta2' is 10, I want to boost pri1 and pri2 with 5 and 10 correspondingly.
I can achieve that with a query of the following form:
{
"query":{
"bool": {
"must": {
},
"must": {
"has_child": {
"type":"meta",
"query": {
"custom_score": {
"query": {"match_all": {}},
"script": "_score * doc['rating'].value"
}
},
"score_type": "sum"
}
}
}
}
}
The above works. However, I am concerned about the performance when it is
done this way. For, let's say, a 100m documents, how would the performance
of the above turn out to be? I am hoping that since both of these are under
the must clause, the first one would run first, and the second one (for
scoring) will be run on the returned results, but of course there can be no
guarantee of that.
Is there a better way to achieve the same? The 'has_child' filter doesn't
seem to accept 'score_type' (I was hoping it was missed during
documentation) so I can't use the filter to do the boosting. I've tried
using the 'has_child' query within a 'query' filter ( ) hoping that that
would somehow magically work, but that doesn't seem to be the case either...
Thanks in advance
--
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.