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:
- Create an index with two types. In my case they have a parent/child relationship. I'm not sure if that is a factor.
- Create a property in the parent that is a string type.
- Create a property in the child, using the same name as the property created in the parent, but make this property a double type.
- Create a parent and child document.
- Try to perform a numeric type aggregation on the child type.
- 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.