Using filters
#Overview
Filtering allows you to restrict the content shown by specific parameters. This is helpful when trying to create a more curated overview of content.
These filters can be useful when building content views, looking for a specific type of content, or finding content that matches several perimeters (such as Created after AND Content ID).
Hygraph does not currently support filtering for Rich Text - even if inside components -, JSON, multi-value fields, colors, or coordinates.
#Filtering by entry
You can find the filters on any content view right at the top. If there are no filters added, this is how it will look like:
Filter Bar
After you applied a filter, for example for a DateTime field, you can add more filters with the "plus" icon or Clear filters.
Apply a Filter
Additionally, you can also filter by fields that allow multiple values. Here's an example for a dropdown field:
Multi-value enum filtering
- Navigate to the content tab in the left-hand sidebar.
- Choose a content model from the collapsible sidebar.
- Press the Filter icon at the end of the filter bar at the top of the content entries table.
- Choose from one of the fields listed for filtering.
- Select the filter method in the center of the filter box (default's to contains).
- Choose from one of the following options:
Option | |
---|---|
Is | Exact match |
Is Null | Matches empty (without content) |
Is Not Null | Matches not null (with any content added) |
Is Not | Exclusion match |
Less Than | for numeric fields (including date and dateTime) |
Less Than or Equal To | for numeric fields (including date and dateTime) |
Greater Than | for numeric fields (including date and dateTime) |
Greater Than or Equal To | for numeric fields (including date and dateTime) |
Contains | String search |
Not Contains | Exclusion by string search |
Starts With | Starting string match |
Not Starts With | Exclusion by starting string match |
Ends With | Ending string match |
Not Ends With | Exclusion by ending string match |
Includes some | for multi-value fields, some of the provided values match |
Includes all | for multi-value fields, all of the provided values match |
Includes none | for multi-value fields, none of the provided values match |
- To the right of the filter method, enter a comparison value.
#Filtering by relations
In order to filter your content entries by a relational field, click the +Filter
button and select one of the referenced models.
Then, select the field of this model that you want to filter for, as well as the condition.
Finally, add the search term you're interested in, or select the value from a dropdown.
As an example, you will be able to build a filtering condition like this: Show all
of the content entries where
the Title
of the referenced Category
is exactly General
.
Screenshot of Filtering by Relations in Hygraph
Please note that it is not possible to filter by union-type reference fields - those that allow you to reference more than one model in a field. For instance, Staff reference field with Players and Coaches models referenced in the Team parent model.
#Filtering by content stage
In order to filter your content by stage, click on the +Filter
button and select Stage
. After this, you must then select a stage from the dropdown, as well as a condition.
Filtering by content stage
#Stages and conditions
While there are three default stages - DRAFT
, PUBLISHED
, and PUBLISHED (!)
- stages other than the default ones can exist in the projects of Scale and Enterprise plans.
Stage Name | Definition |
---|---|
Draft | Content entries that exist in DRAFT , and don't exist in any other stage. This content has never been published. |
Published | Content entries that exist in PUBLISHED and are not outdated. This means that the published version of this content is also the latest version on the system. |
Published (!) | Content entries that exist in PUBLISHED but are outdated. This means there is a version of this document currently published, but there is also another more recent version in the system. |
Please take into account that our stages are not linear and sequential. There are cases where content can be in more than one stage at the same time, such as PUBLISHED and QA. This would happen if, for instance, you edit an already published document, but select the QA stage from the dropdown upon publishing your changes.
Condition | Definition |
---|---|
is | Select this condition to fetch content entries that only exist in the selected stage. |
is not | Select this condition to fetch content entries that do not exist in the selected stage, and only exist in one stage. |
contains | Select this condition to fetch content entries that exist in the selected stage, irrespective of also existing in other stages. This condition will only display for projects with more than two stages. |
doesn't contain | Select this condition to fetch content entries that don't exist in the selected stage, irrespective of also existing in other stages. This condition will only display for projects with more than two stages. |
Please note that stage filtering can also be applied to your project's custom filters. Custom filters creation will result in a state that can be updated or outdated, and the behaviour will be the same as the updated/outdated behaviour shown above for PUBLISHED
and PUBLISHED (!)
.