弹性搜索查询的未知令牌错误 [英] Unknown token error for elastic search query

查看:71
本文介绍了弹性搜索查询的未知令牌错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的ES索引中创建了一个文档.我需要运行搜索查询.

I have created a document in my ES index. I need to run a search query.

这是我的搜索有效载荷.

This is my search payload.

{
"highlight": {
    "require_field_match": true,
    "pre_tags": [
        "<span class=\"searchKeyHighlight\">"
    ],
    "post_tags": [
        "</span>"
    ],
    "fields": {}
},
"query": {
    "query_string": {
        "multi_match": {
            "default_operator": "AND",
            "query": "xyz"
        }
    }
}
}

这是我得到的错误.

{
"error": {
    "root_cause": [
        {
            "type": "parsing_exception",
            "reason": "[query_string] unknown token [START_OBJECT] after [multi_match]",
            "line": 1,
            "col": 170
        }
    ],
    "type": "parsing_exception",
    "reason": "[query_string] unknown token [START_OBJECT] after [multi_match]",
    "line": 1,
    "col": 170
},
"status": 400
}

col 170是搜索查询"multi_match":{"default_operator" 中的multi_match之后的冒号.

The col 170 is the colon after multi_match in the search query "multi_match":{"default_operator".

我使用的是Elasticsearch 5.0.0版.

I am using elasticsearch version 5.0.0.

版本:5.0.0,内部版本:253032b/2016-10-26T04:37:51.531Z,JVM:1.8.0_102

我不明白multi_match查询中出了什么问题.

I don't understand what is wrong in the multi_match query.

推荐答案

请尝试以下查询.您可以使用 query_string multi_match ,您都不能使用.

Try below query. You can use either query_string or multi_match, both you can't use.

{
"highlight": {
    "require_field_match": true,
    "pre_tags": [
        "<span class=\"searchKeyHighlight\">"
    ],
    "post_tags": [
        "</span>"
    ],
    "fields": {}
},
"query": {
    "query_string": {
            "default_operator": "AND",
            "query": "xyz"
         }
     }
}

这篇关于弹性搜索查询的未知令牌错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆