In its most simple form, this does an ‘equals’ compare filter. The
filter keywords expects a list. If the list is two elements long,
we expect the first column to be the filter column name from the
database table, and the second column name to be the filter value:

filter=['numeric_value', `gt`, 10]

If the filter is a three-column list, the second column is the
operator. This must be an atom (surround it in backquotes!) and must
be one of the following: eq, ne, gt, gte, lt,
lte; or one of =, <>, >, >=, <, <=:

Select all resources that have an incoming edge from the given
page, which is specified by the argument (the page id 123 in the
example, or the unique page name tag_gift). Optionally, you can
pass the name of a predicate as the second argument, to specify that
the connection should have this predicate.

So, to select all resources that have an incoming edge from a subject with id
123:

Like hassubject, but selects all pages that have an outgoing edge to
the given page, which is specified by the argument. Optionally, you can pass the
name of a predicate as the second argument, to specify that the connection
should have this predicate:

Like hasobject, but allows to define an OR operation on the edge. You can
define multiple combinations of predicates and objects; any resource having such
an outgoing edge will be matched. The argument is a list. Each element in the
list is either an id or an id/predicate combination.

To select all resources that have an outgoing edge to an object with id 1, 2 or 3:

hasanyobject=[1, 2, 3]

For each list element, you can add the connection’s predicate. So, to select all
resources that have an outgoing ‘author’ edge to an object with id 123:

hasanyobject=[[123, 'author']]

And to do the same but also include resources that have an ‘editor’ edge to an
object with id 456:

hasanyobject=[[123, 'author'], [456, 'editor']]

Substitute '*' for the object id to match any object. So, to select all
resources that have any author or editor edge:

hasanyobject[['*', 'author'], ['*', 'editor']]

You can also mix the two types of elements. To select all resources that have an
author or a connection (with any predicate) to resource 2 or 3:

Sort the result on a field. The name of the field is a string which
directly refers to the SQL join that is being used. If you specify a
dash (-) in front of the field, the order is descending. Leaving
this out or specifying a + means ascending.

The sort terms are added in the order: asort, sort, and zsort.

This is useful for e.g. text search. Text search will add a sort term on
relevance. This relevance sort term is appended after any existing sort term.
By using zsort you can force sub-sorting in case of the same relevance or no
text for the query. Example:

{query cat='news' text=q.qsort zsort="-rsc.created"}

If q.qsort is empty, this will return the newest news items. If q.qsort
is not empty then it will search for the text and return the best matches where
equally matching news items will have the newest on top. Use asort instead
of zsort to show the newest matching news, regardless on how well they match
the search term:

{query cat='news' text=q.qsort asort="-rsc.created"}

Some sort fields:

rsc.modified - date of last modification

rsc.publication_start - publication date

rsc.pivot_date_start - the start date specified in the admin

rsc.pivot_date_end - the end date specified in the admin

rsc.pivot_title - the title of the page. For
multilingual sites, the behavior of sorting on title is undefined.

seq - sequence number of the first edge (ignored if no edge is joined)

edge.created - creation date of the first edge (ignored if no edge is joined)

For all the sort fields, you will have to consult Zotonic’s data
model. Example sorting on modification date, newest first:

All of the filters work as AND filter. The only exception to this
is the cat= filter: if you specify multiple categories, those
categories are “OR“‘ed together, to allow to search in multiple
distinct categories with a single search query.

Query resources are, as the name implies,
Resources of the special category query. In
the admin this category is called “search query”. it is basically a
stored (and thus content manageable) search query. You create an
editable search query in an admin page that then is invoked from a
template.

When creating such a resource in the page, you will see on the admin
edit page an extra text field in which you can add search terms. Each
search term goes on its own line, and the possible search terms are
equal to the ones described on this page (the Query-model
arguments).