簡體   English   中英

Elasticsearch查詢中的排除給出了無法解析搜索源的信息。 預期的字段名稱,但獲得了[START_OBJECT]

[英]Exclude in elasticsearch query gives failed to parse search source. expected field name but got [START_OBJECT]

我有以下查詢,該查詢1.獲取所有具有logtype錯誤的數據。 2.排除logmessage字段中error occured所有數據。

curl -s -XGET 'localhost:9200/index_name/type/_search?pretty=true&size=10' -d '
{
    "query": {
        "match" : {
            "logtype" : "error"
        },
        "should": {
            "bool": {
               "must_not": {
                  "match": {
                     "logMessage": "*error occured*"
                  }
               }
            }
         }
    }
}
'

但是上面的命令給出:

 {
    "error": {
        "root_cause": [{
            "type": "parse_exception",
            "reason": "failed to parse search source. expected field name but got [START_OBJECT]"
        }],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [{
            "shard": 0,
            "index": "indexname",
            "node": "HxII3rajS4KP5dkP-ZvPSw",
            "reason": {
                "type": "parse_exception",
                "reason": "failed to parse search source. expected field name but got [START_OBJECT]"
            }
        }]
    },
    "status": 400
 }

如何解決?

嘗試這個:

curl -s -XGET 'localhost:9200/index_name/type/_search?pretty=true&size=10' -d '{
  "query": {
    "bool": {
      "must": {
        "match": {
          "logtype": "error"
        }
      },
      "must_not": {
         "match": {
           "logMessage": "*error occured*"
         }
      }
    }
  }
}'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM