These examples illustrate how to build relationship filter queries.
The user
may first issue a query for
Editor
records for an editor named Jane Smith who works
in the city of Boston:
collection()/record [ editor_name = "Jane Smith" and editor_city = "Boston" ]
The query is then modified for
Author
records:
collection()/record [ author_editorref = collection()/record [ editor_name = "Jane Smith" and editor_city = "Boston" ] /editor_id ]
The query returns all
Author
records filtered by the results of the
Editor
records. That is, the
Author
records are filtered by the
editor_id
property of the
Editor
records (which are referenced by the
author_editorref
property in the
Author
records).
The next example query returns books by American authors:
collection()/record [ book_authorref = collection()/record [ author_nationality = "american" ] /author_id ]
The next example query returns all books by authors who are still alive:
collection()/record [ book_authorref = collection()/record [ author_deceased ="false" ] /author_id ]
The next example query combines the two previous examples, and also
illustrates the use of the
or
operator. Both inner
collection()/record
functions use the
author_id
property value results as indexes for the
Book
records.
collection()/record [ book_authorref = collection()/record [ author_nationality = "american" ] /author_id or book_authorref = collection()/record [ author_deceased="false" ] /author_id ]
The next example query returns the books written by authors who have had those books published in a hard-cover format.
collection()/record [ book_authorref=collection()/record [ author_bookref=collection()/record [ book_cover = "hard" ] /book_id ] /author_id ]
The next query example extends the previous one by returning the books written by authors who have published hard-cover books and have worked with an editor named "Jane Smith". The query also shows how to apply relationship filters among all three record types.
collection()/record [ book_authorref=collection()/record [ author_bookref=collection()/record [ book_cover="hard" ] /book_id and author_editorref=collection()/record [ editor_name="Jane Smith" ] /editor_id ] /author_id ]
In the final example, this powerful query returns all books written by the author of a play titled "The Island Princess" (which was written by English playwright John Fletcher) and also all books that were written by authors who co-wrote books with Fletcher. The result set will include plays that were written either by Fletcher or by anyone who has ever co-authored a play with Fletcher.
collection()/record [ book_authorref = collection()/record [ author_bookref = collection()/record [ book_authorref = collection()/record [ author_bookref = collection()/record [ book_title = "The Island Princess" ] /book_id ] /author_id ] /book_id ] /author_id ]