{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: [histogram] field do not support searching, use dedicated aggregations instead: [my_histogram]",
"index_uuid": "ASpPxIayTyq4zA-XS77ZUA",
"index": "my-index-000001"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "my-index-000001",
"node": "KFidmtZDSuGMeFwn7qhA_A",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: [histogram] field do not support searching, use dedicated aggregations instead: [my_histogram]",
"index_uuid": "ASpPxIayTyq4zA-XS77ZUA",
"index": "my-index-000001",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "[histogram] field do not support searching, use dedicated aggregations instead: [my_histogram]"
}
}
}
]
},
"status": 400
}
Histogram fields can be used only for aggregations like min,max, etc. and can also by used in composite aggs which are used under the hood for SQL GROUP BY queries:
If histogram field type is to be returned in a simple SELECT my_histogram FROM ... or SELECT * FROM ... then special care should be taken for the (also for JDBC/ODBC) as the search results look like this:
Following https://github.com/elastic/elasticsearch/pull/63289 it would be nice to also support this field type in SQL. Currently if such a field is present in an index,
SELECT * FROM my-index
just skips the field. Using the example of https://www.elastic.co/guide/en/elasticsearch/reference/master/histogram.html#histogram-ex,SELECT * FROM "my-index-000001"
returns:Where as
SELECT my_histogram from "my-index-000001"
throws an exception as expected:returns:
min
,max
, etc. and can also by used in composite aggs which are used under the hood for SQL GROUP BY queries:returns:
SELECT my_histogram FROM ...
orSELECT * FROM ...
then special care should be taken for the (also for JDBC/ODBC) as the search results look like this: