Elasticsearch query string query with not equal to?
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"
}
}
}
}
}
You can also use a combination of must and must_not. Like pull docs where name is Ajit and status is not queued.
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "Ajit"
}
}
],
"must_not": [
{
"match": {
"status": "queued"
}
}
]
}
}
}
and, or and not filters
***For "and" query:***
"filtered" : {
"query" : {
"term" : { "name.first" : "shay" }
},
"filter" : {
"and" : {
"filters" : [
{
"term" : { "name.first" : "something" }
},
{
"term" : { "name.first" : "other" }
}
]
}
}
}
***For "or" query:***
{
"filtered" : {
"query" : {
"term" : { "name.first" : "shay" }
},
"filter" : {
"or" : {
"filters" : [
{
"term" : { "name.first" : "something" }
},
{
"term" : { "name.first" : "other" }
}
]
}
}
}
}
***For "not" query:***
{
"filtered" : {
"query" : {
"term" : { "name.first" : "shay" }
},
"filter" : {
"not" : {
"filter" : {
"term" : { "name.first" : "someting" }
}
}
}
}
}