I have one index containing various types. It does happen, that a field with the same name is mapped as string in one type and as integer in another type.
The following query on a type t1, where "sample_field" is mapped as string
{
"query": {
"match_all": {}
},
"facets": {
"stats": {
"statistical": {
"field": "sample_field"
}
}
}
}
results in:
=> FacetPhaseExecutionException[Facet [stats]: field [sample_field] isn't a number field, but a string]
which is of course the expected feedback
The same query a type t2, where "sample_field" is mapped as integer, leads to the following error:
=> NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]
I know I could either rename the fields or put the types in different indexes to avoid this error.
I want to keep the mappings as they are.
Is there a more elegant way to solve this issue?
I also tried it with
{
"query": {
"match_all": {}
},
"facets": {
"t2.stats": {
"statistical": {
"field": "t2.sample_field"
}
}
}
}
but that results in the same error message.
Unfortunately, no you can't do this at the moment. You'd have to make all
your field types the same, or use different field names. If they are all in
the same index in different types with different data types and same field
names, you'll unfortunately encounter this limitation.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.