Fulltext Search with Java

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

The fulltext predicate searches the term in any of the following fields:

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

To learn more about this predicate checkout the Query predicate reference page.

Note that the fulltext search is not case sensitive.

Search the entire document

This example shows how to query for all the documents of the custom type "blog_post" that contain the word "prismic".

Copy
Response response = api.query(
        Predicates.at("document.type", "blog_post"),
        Predicates.fulltext("document", "prismic")
    ).submit();
List<Document> documents = response.getResults();

Search a specific field

The fulltext predicate can also be used to search a specific Rich Text, Key Text, UID, or Select field for a given term.

The following example shows how to query for all the documents of the custom type "article" whose "title" field contains the word "turtle".

Copy
Response response = api.query(
        Predicates.at("document.type", "article"),
        Predicates.fulltext("my.article.title", "turtle")
    ).submit();
List<Document> documents = response.getResults();