ElasticGraph Query API: Filter Negation
Try these example queries by visiting the GraphiQL UI after booting locally.
Copied!
$ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always
ElasticGraph supports a negation predicate:
not
- Matches records where the provided sub-filter evaluates to false.
This works just like a
NOT
operator in SQL.When
null
or an empty object is passed, matches no documents.
One of the more common use cases is to filter to non-null values:
Copied!
query FindNamedVenues {
venues(filter: {
name: {not: {equalToAnyOf: [null]}}
}) {
nodes {
name # will be non-null on all returned nodes
capacity
}
}
}
not
is available at any level of a filter
. These are equivalent:
name: {not: {equalToAnyOf: [null]}}
not: {name: {equalToAnyOf: [null]}}