title: elasticsearch / kibana 4: field exists but is not equal to a value
body: <p>elasticsearch version 1.4.5</p>
  
  <p>kibana 4.1.1</p>
  
  <p>logstash 1.5.2-1</p>
  
  <p><strong>How do I structure a search in the discover tab of kibana 4 that only returns results if a field exists but is not equal to a specific value?</strong></p>
  
  <p>I have some apache log data in logstash and I want to return all entries that have <code>status_code</code> defined but not equal to 200.  So if the possible values are {undefined, 200, 403, 404, 500, etc} I would like to see all variants of 4xx and 5xx errors but not messages where the field is not defined and not where it is set to 200.</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>+status_code: (*) -status_code: (200)
  
  ((status_code: (*) AND NOT status_code: (200))
  </code></pre>
  
  <p>I also see references to elasticsearch <a href="https://stackoverflow.com/questions/14745210/create-elasticsearch-curl-query-for-not-null-and-not-empty">curl queries</a> but I'm not sure how to turn them into something that I can use in the kibana search bar.  Here is an example:</p>
  
  <pre><code>{
    "query": {
      "constant_score": {
        "filter": {
          "bool": {
            "must": {
              "exists": {
                "field": "status_code"
              }
            },
            "must_not": {
              "term": {
                "status_code": '200'
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Thanks!</p>