Fulltext Search with the REST API

You can use the Fulltext predicate to search a document for a given term or terms.

It searches the term(s) in any of the following fields:

  • Rich Text
  • Title
  • Key Text
  • UID
  • Select

To learn more about this predicate checkout the Fulltext section on the Query Predicate Reference page.

Note that the fulltext search is not case sensitive.

The Fulltext predicate

Here is the predicate you need when querying all of the documents of a certain custom type.

Copy
[fulltext(document, "{search-terms}")]

You just need to enter the term(s) for the search. The following is the predicate that will query for all documents that contain the word "football".

Copy
[fulltext(document, "football")]

Example with a single search term

The following example shows the url used to query all the documents of the custom type "blog-post" that contain the word "prismic".

Here are all the required parameters for this query:

all of type "blog-post"

q=[[at(document.type,"blog-post")]]

search for "prismic"

q=[[fulltext(document,"prismic")]]

Example with multiple search terms

The following example shows the url used to query all the documents of the custom type "article" that contain both the word "cookies" and "chocolate".

When searching multiple terms, the document must contain all the search terms. To enter multiple terms, simply put a space between the words as shown below.

Here is what the required parameters for this query look like:

all of type "article"

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

search for terms

q=[[fulltext(document,"cookies chocolate")]]