Query by a field with the REST API

There are a number of fields that you can query content by. Here are examples of how to query by the Number, Select, and Key Text fields.

Query by a Number Field

This example shows how to query all the products with the price field (Number) less than 100. To do this, we'll be using the lt (less than) predicate.

Here are all the required parameters for this query:

all of type "product"

q=[[at(document.type,"product")]]

price less than 100

q=[[number.lt(my.product.price,100)]]

You can find more query predicates for Number fields on the Query Predicate Reference page.

Query by a Key Text Field

This queries all the "employee" custom type documents with the job-title field (Key Text) equal to either "Developer" or "Designer". To do the either operation we will need to use the any predicate.

Here are all the required parameters for this query:

all of type "employee"

q=[[at(document.type,"employee")]]

either Key Text value

q=[[any(my.employee.job-title,["Developer","Designer"])]]

To query by a particular document link value, you must use the ID of the document you are looking for.

The following example queries all the "blog_post" custom type documents with the "category_link" field (a Document Link) equal to the category with a document ID of "WNje3SUAAEGBu8bc".

Here are all the required parameters for this query:

all of type "blog_post"

q=[[at(document.type,"blog_post")]]

with certain category link

q=[[at(my.blog_post.category_link,"WNje3SUAAEGBu8bc")]]

Query by a Select Field

The following example shows a query for all the "book" custom type documents with the author field (Select) equal to "John Doe". It also sorts the results by their title.

Here are all the required parameters for this query:

all of type "book"

q=[[at(document.type,"book")]]

select equal to "John Doe"

q=[[at(my.book.author,"John Doe")]]

sort by title

orderings=[my.book.title]