【问题标题】:error using aggregations in elasticsearch在弹性搜索中使用聚合时出错
【发布时间】:2021-06-18 15:05:59
【问题描述】:

我正在使用 elasticsearch java Api,我正在尝试运行此查询来检索结果。但我遇到了一个解析异常。 你能帮我弄清楚问题出在哪里吗? 我将不胜感激

{
    "size": 0,
    "query": {
        "bool": {
            "must": [{
                    "query_string": {
                        "query": "data~ AND gaps~",
                        "default_field": "all_muses",
                        "fields": [],
                        "type": "best_fields",
                        "default_operator": "or",
                        "max_determinized_states": 10000,
                        "enable_position_increments": true,
                        "fuzziness": "AUTO",
                        "fuzzy_prefix_length": 0,
                        "fuzzy_max_expansions": 50,
                        "phrase_slop": 0,
                        "escape": false,
                        "auto_generate_synonyms_phrase_query": true,
                        "fuzzy_transpositions": true,
                        "boost": 1.0
                    }
                }
            ],
            "adjust_pure_negative": true,
            "boost": 1.0
        }
    },
    "aggregations": {
        "groupBySerie": {
            "terms": {
                "field": "titreSerie",
                "size": 6,
                "min_doc_count": 1,
                "shard_min_doc_count": 0,
                "show_term_doc_count_error": false,
                "order": [{
                        "_count": "desc"
                    }, {
                        "_key": "asc"
                    }
                ]
            },
            "aggregations": {
                "groupBySf": {
                    "terms": {
                        "field": "sousFamille",
                        "size": 10,
                        "min_doc_count": 1,
                        "shard_min_doc_count": 0,
                        "show_term_doc_count_error": false,
                        "execution_hint": "global_ordinals_low_cardinality",
                        "order": [{
                                "_count": "desc"
                            }, {
                                "_key": "asc"
                            }
                        ]
                    }
                }
            }
        }
    }
}

这是我得到的例外

ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]]; nested: ElasticsearchException[Elasticsearch exception 
[type=parse_exception, reason=parse_exception: Encountered " ":" ": "" at line 1, column 36.
20:55:55,464 INFO  [stdout] (http-localhost/127.0.0.1:8080-3) Was expecting one of:
20:55:55,464 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <NOT> ...
20:55:55,464 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     "+" ...
20:55:55,464 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     "-" ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <BAREOPER> ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     "(" ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     "*" ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <QUOTED> ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <TERM> ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <PREFIXTERM> ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <WILDTERM> ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <REGEXPTERM> ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     "[" ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     "{" ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <NUMBER> ...
20:55:55,465 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     <TERM> ...
20:55:55,466 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     "*" ...
20:55:55,466 INFO  [stdout] (http-localhost/127.0.0.1:8080-3)     ]];

“我正在使用 elasticsearch java Api,我正在尝试运行此查询来检索结果。但我遇到了解析异常。 你能帮我弄清楚问题出在哪里吗? 我将不胜感激”

【问题讨论】:

    标签: java elasticsearch elasticsearch-aggregation elasticsearch-java-api elasticsearch-7


    【解决方案1】:

    execution_hint 参数不接受 global_ordinals_low_cardinality 值,而只接受 mapglobal_ordinals

    您需要确保您的客户端 Java API 的版本与您的 ES 集群的版本同步,因为您似乎使用的是旧的客户端 Java API。

    【讨论】:

    • 你好不是问题和版本相同
    • 那是什么问题?您使用 elasticsearch-7 标记了问题,但您运行的是 6.x 版本吗?
    • 我还没有找到解决方案。是的,我们使用的是 elasticsearch 7.6 版。但我认为问题出在“”查询“:“数据〜AND空白〜”,当我用一个词搜索时我没有错误?知道为什么吗?我将默认运算符更改为,但我得到相同的错误?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-05
    • 2017-03-10
    • 1970-01-01
    • 2017-12-30
    • 2019-11-08
    • 2021-02-19
    • 2023-03-18
    相关资源
    最近更新 更多