![](/img/trans.png)
[英]Problem with Elasticsearch query - [range] malformed query, expected [END_OBJECT] but found [FIELD_NAME]
[英]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.