Queries custom_score, has_parent, has_child used with only filters

I created an issue about not being able to specify filters on a lot of
levels in the query DSL:

So for instance this has_parent filter:
{
"has_parent": {
"type": "accos",
"query": {
"filtered": {
"filter": {
"term": {
"locationCode": "0512"
}
}
}
}
}
}

This is very verbose and could (in theory) be specified like this:
{
"has_parent": {
"type": "accos",
"filter": {
"term": {
"locationCode": "0512"
}
}
}
}

Being a filter itself, the has_parent filter now takes a query, which seems
strange.

For query's has_child, has_parent and custom_score, I also see myself doing
this. For example:

{
"query": {
"filtered": {
"query": {
"has_child": {
"type": "prices",
"score_type": "max",
"query": {
"custom_score": {
"script": "-doc['pricePerPerson'].value",
"query": {
"filtered": {
"filter": {
"term": {
"careType": "LO"
}
}
}
}
}
}
}
},
"filter": {
"term": {
"locationCode": "0512"
}
}
}
}
}

The custom score query doesn't use _score in the script field, and to be
able to use caching I want a filter, so I have to use a filtered query.
This could have been written (again, in theory) like this:

{
"query": {
"filtered": {
"query": {
"has_child": {
"type": "prices",
"score_type": "max",
"query": {
"custom_score": {
"script": "-doc['pricePerPerson'].value",
"filter": {
"term": {
"careType": "LO"
}
}
}
}
}
},
"filter": {
"term": {
"locationCode": "0512"
}
}
}
}
}

In fact, I think this could be applied to lots of query types that only
take a query parameter now.

Are there any (possibly technical) things I'm missing?

Jaap

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