elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.12k stars 24.83k forks source link

SQL: Add support for histogram field #74658

Closed matriv closed 7 months ago

matriv commented 3 years ago

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:

    my_text    
---------------
histogram_1    
histogram_2   

Where as SELECT my_histogram from "my-index-000001" throws an exception as expected:

{
    "error": {
        "root_cause": [
            {
                "type": "verification_exception",
                "reason": "Found 1 problem\nline 1:8: Cannot use field [my_histogram] with unsupported type [histogram]"
            }
        ],
        "type": "verification_exception",
        "reason": "Found 1 problem\nline 1:8: Cannot use field [my_histogram] with unsupported type [histogram]"
    },
    "status": 400
}

returns:

{
    "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
}

returns:

{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 2,
            "relation": "eq"
        },
        "max_score": null,
        "hits": []
    },
    "aggregations": {
        "groupby": {
            "after_key": {
                "adc46d04": "histogram_2"
            },
            "buckets": [
                {
                    "key": {
                        "adc46d04": "histogram_1"
                    },
                    "doc_count": 1,
                    "f98450ce": {
                        "value": 0.32156862745098036
                    }
                },
                {
                    "key": {
                        "adc46d04": "histogram_2"
                    },
                    "doc_count": 1,
                    "f98450ce": {
                        "value": 0.2989583333333333
                    }
                }
            ]
        }
    }
}
elasticmachine commented 3 years ago

Pinging @elastic/es-ql (Team:QL)

elasticsearchmachine commented 9 months ago

Pinging @elastic/es-analytical-engine (Team:Analytics)

wchaparro commented 7 months ago

Superceded by ES|QL / TSDB initiative