Percolate Query using _size matches no documents

Is filtering on the _size field allowed on percolate requests?

Adding into a percolate query in either a filter or the query section a _size range matches no documents.

Walking through reproducing the problem:

Register the query:

curl -XPUT 'http://localhost:9200/_percolator/test_index/queryNamedSue' -d '{
"query" : {
"constant_score": {
"filter": {
"and": [ {
"query" : {
"query_string" : {
"query" : "batman",
"default_field" : "all"
}
}
}, {
"bool" : {
"must" : [ {
"term" : { "ni.language" : "en" }
}, {
"range" : {
"_size" : {
"from" : 0,
"to" : 10000,
"include_lower" : true,
"include_upper" : true
}
}
} ]
}
} ]
}
}
}
}'

Then percolate a document (aside: 'ni.content' field in our mapping is a default search field):

curl -XGET 'http://localhost:9200/test_index/testType/_percolate' -d '{
"doc": {
"ni": {
"content": "So Batman walks into a bar",
"language": "en"
}
}
}'

Which results in

{"ok":true,"matches":["queryNamedSue"]}

Now if the query is changed to include a _size range,

curl -XPUT 'http://localhost:9200/_percolator/test_index/queryNamedSue' -d '{
"query" : {
"constant_score": {
"filter": {
"and": [ {
"query" : {
"query_string" : {
"query" : "batman",
"default_field" : "all"
}
}
}, {
"bool" : {
"must" : [ {
"term" : { "ni.language" : "en" }
}, {
"range" : {
"_size" : {
"from" : 0,
"to" : 10000,
"include_lower" : true,
"include_upper" : true
}
}
} ]
}
} ]
}
}
}
}'

Percolating the same document yields

{"ok":true,"matches":[]}

I have researched and found that percolating with a mapping that enables and stores _size was failing over a year ago, but this issue was patched: https://github.com/elasticsearch/elasticsearch/pull/2353.

We set a default template that for all types in the mapping enables _size and sets it to store. Our percolator node uses the following configuration:

Index Settings:

index.number_of_shards: variesBasedOnWorkload
index.number_of_replicas: 0
index.auto_expand_replicas: "false"
index.dynamic: "true"
index.mapper.dynamic: "true"
index.store.compress.stored: "true"
index.store.compress.tv: "true"
index.term_index_divisor: "4"
index.merge.scheduler.max_thread_count: 1

Node Settings:

cache.memory.direct: "false"
http.enabled: "false"
gateway.type: "none"
index.store.type: "memory"