tbo
tbo

Reputation: 9758

Elasticsearch Aggregation - Unable to perform aggregation to object

I have a mapping with an inner object as follows:

{
    "mappings": {
        "_all": {
            "enabled": false
        },
        "properties": {
            "foo": {
                "name": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "address": {
                    "type": "object",
                    "properties": {
                        "address": {
                            "type": "string"
                        },
                        "city": {
                            "type": "string",
                            "index": "not_analyzed"
                        }
                    }
                }
            }
        }
    }
}

When I try the following aggregation it does not return any data:

post data:*/foo/_search?search_type=count
{
  "query": {
    "match_all": {}
  },
  "aggs": {
    "unique": {
      "cardinality": {
        "field": "address.city"
      }
    }
  }
}

When I try to put field city or address.city, aggregation returns zero but if i put foo.address.city it is then when i get the correct respond by elasticsearch. This also affects kibana behavior

Any ideas why this is happening? I saw there is a mapping refactoring that might affects this. I use elasticsearch version 1.7.1

To add on this if, I use the relative path in a search query as follows it works normally:

"query": {
    "filtered": {
      "filter": {
        "term": {
          "address.city": "london"
        }
      }
    }
  }

Upvotes: 0

Views: 99

Answers (1)

Vineeth Mohan
Vineeth Mohan

Reputation: 19253

Seems its this same issue. This is seen when the type name and field name is same.

Upvotes: 2

Related Questions