2017-04-06 40 views
2

匹配的文字我想不匹配「的StatusCode」的結果:200Elasticsearch查詢不能從現場

爲了從字段相匹配的文本使用

GET index01/_search?pretty 
{ 
    "query":{ 
    "match":{ 
     "statusCode": 200 
    } 
    } 
} 

我想是這樣這樣的:

GET ucs_heartbeat/_search?pretty 
{ 
    "query":{ 
    "match":{ 
     "statusCode":{ 
     "query": 200, 
     "operator": "must_not" 
     } 
    } 
    } 
} 

據:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

+1

請注意,「匹配查詢」沒有_operator_名爲'must_not'。只有可用的操作符是'和'(默認)和'或'。考慮對所有結構化字段(如「關鍵字」,「數字」)使用'term'查詢 – avr

回答

5

試試這個插件tead

GET ucs_heartbeat/_search?pretty 
{ 
    "query": { 
    "bool": { 
     "must_not": [ 
     { 
      "term": { 
      "statusCode": 200 
      } 
     } 
     ] 
    } 
    } 
}