搜索时出现弹性搜索查询字符串问题

时间:2018-01-29 11:58:41

标签: elasticsearch

我正在进行弹性搜索,现在我有一系列电话号码,我想通过弹性搜索进行搜索,但我不知道我在下面的编写代码中的错误是我的工作代码

contacts = ["+966","+965"];

    let getPhoneSearchUsers = function (login_user,contacts:any) {

        if(_.size(contacts)>0){
            return {
                "_source": ["id", "username", "full_name","phone"],
                "query": {
                    "bool": {
                        "should": [
                            {
                                "prefix": { "phone":contacts }
                            }
                        ],
                        "must_not" : [
                            {
                                "ids": {"values": [login_user]}
                            }
                        ]
                    }
                }
            }
        }

    }

我总是收到以下异常

{
  "error": {
    "root_cause": [
      {
        "type": "json_parse_exception",
        "reason": "Unexpected character (',' (code 44)): was expecting a colon to separate field name and value\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@3520c9; line: 8, column: 35]"
      }
    ],
    "type": "json_parse_exception",
    "reason": "Unexpected character (',' (code 44)): was expecting a colon to separate field name and value\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@3520c9; line: 8, column: 35]"
  },
  "status": 500
}

任何人都可以让我知道我在代码中的错误吗?

0 个答案:

没有答案