-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Open
Labels
:Search Relevance/SearchCatch all for Search RelevanceCatch all for Search Relevance>enhancementTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchMeta label for the Search Relevance team in Elasticsearch
Description
Elasticsearch version (bin/elasticsearch --version): 7.15.0
Description of the problem including expected versus actual behavior:
When sorting search results from two different indices, if a field is defined as a long in one index and a float in the other index, a ClassCastException is thrown rather then Elasticsearch coalescing both values to a "numeric" value and sorting them.
Steps to reproduce:
PUT long
{
"mappings": {
"properties": {
"foo": {
"type": "long"
}
}
}
}
PUT float
{
"mappings": {
"properties": {
"foo": {
"type": "float"
}
}
}
}
POST long/_doc/1
{
"foo": "123"
}
POST float/_doc/1
{
"foo": 1.23
}
POST long,float/_search
{ "sort": "foo" }
The last query returns:
{
"error" : {
"root_cause" : [ ],
"type" : "search_phase_execution_exception",
"reason" : "",
"phase" : "fetch",
"grouped" : true,
"failed_shards" : [ ],
"caused_by" : {
"type" : "class_cast_exception",
"reason" : "class java.lang.Float cannot be cast to class java.lang.Long (java.lang.Float and java.lang.Long are in module java.base of loader 'bootstrap')"
}
},
"status" : 500
}
This is the case even if one of the documents has the field defined with a null value- as long as the mapping of the field differs, this exception is thrown.
Related:
Metadata
Metadata
Assignees
Labels
:Search Relevance/SearchCatch all for Search RelevanceCatch all for Search Relevance>enhancementTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchMeta label for the Search Relevance team in Elasticsearch