ElasticGraph Query API: List Filtering
ElasticGraph supports a couple predicates for filtering on list fields:
anySatisfy
- Matches records where any of the list elements match the provided sub-filter.
Will be ignored when
null
or an empty object is passed. count
- Used to filter on the number of non-null elements in this list field.
Will be ignored when
null
or an empty object is passed.
Filtering on list elements with anySatisfy
When filtering on a list field, use anySatisfy
to find records with matching list elements.
This query, for example, will find artists that released a platinum-selling album in the 1990s:
One thing to bear in mind: this query is selecting which artists to return,
not which albums to return. You might expect that the returned nodes.albums
would
all be platinum-selling 90s albums, but that’s not how the filtering API works. Only artists
that had a platinum-selling 90s album will be returned, and for each returned artists, all
their albums will be returned–even ones that sold poorly or were released outside the 1990s.
Filtering on the list size with count
If you’d rather filter on the size of a list, use count
: