Search code examples
elasticsearch

Elasticsearch query string query with not equal to?


Usually with a query_string query in elasticsearch, I can do:

name:"Fred"

I want to find all documents where name is not equal to Fred. What is the proper syntax for that? I tried:

name!="Fred"

Though it returns 0 documents.


Solution

  • You need to use the NOT operator, like this:

    !(name:"Fred")
    

    or

    NOT (name:"Fred")