Possible aggregation bug

I've discovered what I feel is a bug, please correct me if I am wrong. The issue is that when executing an aggregation I get an error that says "org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData". In my research I find comments that this is because I'm trying to perform a numeric aggregation on a string.

The problem is, that this particular field is mapped as a double. Further, if in the query for my aggregation I return only one document, and the value of that field is clearly numeric, I still end up with the error. There are other fields in the document that are mapped as doubles and the aggregations work as expected. It is just this one field that is throwing the error.

What I discovered is that there is another Type in the index which has a field with the same name, but is mapped to a string. If I rename one of the fields, I no longer get the error. I could understand the error if I was querying across all Types, but I'm not, I'm specifying a specific Type in my aggregation and yet the mapping from some other Type is causing my aggregation to barf.

Here is how to repro:

  1. Create an index with two types. In my case they have a parent/child relationship. I'm not sure if that is a factor.
  2. Create a property in the parent that is a string type.
  3. Create a property in the child, using the same name as the property created in the parent, but make this property a double type.
  4. Create a parent and child document.
  5. Try to perform a numeric type aggregation on the child type.
  6. The error will happen here.

Is this a bug, or am I doing something wrong? Is there a work around other than renaming the field, which would be inconvenient since we are in production.

Thank you.


This isn't a bug, the problem is that you have a mapping conflict. Elasticsearch doesn't support different mappings in two different types in the same index. However it tries to deal with this in a best effort sort of way. See this URL:


"Field names with the same name across types are highly recommended to have the same type and same mapping characteristics (analysis settings for example). There is an effort to allow to explicitly "choose" which field to use by using type prefix (my_type.my_field), but it’s not complete, and there are places where it will never work (like faceting on the field)."

Also I suggest you read the following because in Elasticsearch 2.0 all fields with the same name in the same index must have the same mapping:


Thanks much for the response and education :smile: