LalitKumar
LalitKumar

Reputation: 11

Elasticsearch : get compliment of output

I want to get set of result which is outside the provided filters. Example :

Query : document_id and filter
{
   Document_id : 1,2,3,4,5,6,7
},
{
   Query Result : 1,2,3,4,5,6
}

Output : 7

I can perform the above manipulation in java code as well but I want to get this result from Query. Any help would be appreciated.

Upvotes: 1

Views: 72

Answers (1)

Doron Yaacoby
Doron Yaacoby

Reputation: 9770

You should put your filter in a must_not clause inside a bool query, like this:

POST _search
{
  "query": {
    "bool" : {
      "must_not" : [
        <YOUR FILTER QUERIES HERE>
      ]
    }
  }
}

Upvotes: 1

Related Questions