I cannot make an elasticsearch + aggregation filter to work with nested fields. The data schema (corresponding part) is as follows:
"mappings": { "rb": { "properties": { "project": { "type": "nested", "properties": { "age": { "type": "long" }, "name": { "type": "string", "index": "not_analyzed" } } } } } }
In essence, the “rb” object contains a nested “project” field, which contains two more fields - “name” and “age”. Request I run:
"aggs": { "root": { "aggs": { "group": { "aggs": { "filtered": { "aggs": { "order": { "percentiles": { "field": "project.age", "percents": ["50"] } } }, "filter": { "range": { "last_updated": { "gte": "2015-01-01", "lt": "2015-07-01" } } } } }, "terms": { "field": "project.name", "min_doc_count": 5, "order": { "filtered>order.50": "asc" }, "shard_size": 10, "size": 10 } } }, "nested": { "path": "project" } } }
In this query, it is supposed to create 10 best projects (project.name field) that correspond to a date filter sorted by their average age, ignoring projects with less than 5 references in the database. The median should only be calculated for projects matching the filter (date range).
Despite the presence of more than hundreds of thousands of objects in the database, this query creates an empty list. No errors, just an empty answer. I tried this on both ES 1.6 and ES 2.0 beta.
source share