Not Query Usageedit

A query that filters out matched documents using a query.

Deprecated in 2.1.0. Use the bool query with must_not clause instead.

See the Elasticsearch documentation on not query for more details.

Fluent DSL exampleedit

q
.Not(c => c
    .Name("named_query")
    .Boost(1.1)
    .Filters(
        qq => qq.MatchAll(m => m.Name("query1")),
        qq => qq.MatchAll(m => m.Name("query2"))
    )
)

Object Initializer syntax exampleedit

new NotQuery()
{
    Name = "named_query",
    Boost = 1.1,
    Filters = new QueryContainer[] {
        new MatchAllQuery() { Name = "query1" },
        new MatchAllQuery() { Name = "query2" },
    }
}

Example json output.

{
  "not": {
    "_name": "named_query",
    "boost": 1.1,
    "filters": [
      {
        "match_all": {
          "_name": "query1"
        }
      },
      {
        "match_all": {
          "_name": "query2"
        }
      }
    ]
  }
}