Has_parent slow in filter, fast in query?

We ran into a problem with a slow query. Turns out having a has_child (or
has_parent) query in the "filter" part of a "filtered" query is a lot
slower than having the same has_child filter in the "query" part of the
"filtered" query.

The faster of the two queries runs in under 100ms, while the slower one
takes 250-300ms. I don't understand why these would have different run
times, any ideas?

The index is around 2GB. The child with about 600,000 docs, the parent with
about 3,000,000 docs.

These are the two queries:

Slower:

"query": {
"filtered": {
"filter": {
"and": {
"filters": [
{
"range": {
"price": {
"gt": "0"
}
}
},
{
"has_parent": {
"type": "product",
"query": {
"match_all": {}
}
}
}
]
}
}
}
}

Faster:

"query": {
"filtered": {
"query": {
"has_parent": {
"type": "product",
"query": {
"match_all": {}
}
}
},
"filter": {
"and": {
"filters": [
{
"range": {
"price": {
"gt": "0"
}
}
}
]
}
}
}
}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d811bca1-9798-49c5-b1f6-79cb5857f547%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.