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.
Similarly, to find documents whose field value is NOT equal to a given query string, you can do so using the NOT operator. If you want to find documents whose field value does not match multiple values, you need to use a space separated list. NOTE: you can also get the same results using a must_not boolean query.
One of the most common queries in elasticsearch is the match query, which works on a single field. And there's another query with the very same options that works also on multiple fields, called multi_match. These queries support text analysis and work really well.
You need to use the NOT operator, like this:
!(name:"Fred")
or
NOT (name:"Fred")
You should use bool query with must_not statement
{ "query": { "bool" : { "must_not" : { "term" : { "name" : "Fred" } } } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With