The following types of filters are supported:
Let’s look at some filters in detail. The nodeType
filter filters out documents that don’t match the specified node type. You can also indicate whether you want to include subnodes or not. The example filters on page nodes and their subnodes. The author
filter only takes one parameter value, which is a string representing a user’s name.
{
jcr {
searches(siteKey: "digitall", language: "en", workspace: LIVE) {
search(...,
sortBy:{...},
filter:{
nodeType:{nodeType:"jnt:page", includeSubNodes:true}
author:{value:"root"}}}) {
...
}
}
}
}
A date filter can take a string representation of a date or date math expression. Three constraint types are available:
equal
constraint, before
and after
are ignored by your search.You can use a single filter or combine all four filters together for added flexibility. Here’s an example of a query that uses two filters.
{
jcr {
searches(siteKey: "digitall", language: "en", workspace: LIVE) {
search(...,
sortBy:{...},
filter:{author:{value:"root"}, published:{before:"now-1d/d"}}) {
...
}
}
}
}
Advanced filtering gives you full control of the property you want to filter on. You use a custom object to specify term, dateRange and numberRange filters. This allows you to have one or more filters of the same type (term, number range, date range), which can be ANDed or ORed together for greater flexibility. Here’s an example of a term filter.
{
jcr {
searches(siteKey: "digitall", language: "en", workspace: LIVE) {
search(...,
sortBy:{...},
filter:{
custom:{
term:[{operation:OR, terms:[{field:"jcr:createdBy" value:"root"}]}]
}
}
{
...
}
}
}
}
In this case, the result set is filtered to contain entries created by “root”, the use of OR is not really necessary and is here just for demonstration purposes. Note that this is similar to the above example of author filter, the difference is that the author filter is a shortcut designed for convenience, while the term group can be used to filter on any property.