Fulltext Search in Javascript

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

The fulltext predicate searches the term in the Rich Text, Key Text, UID, and Select Fields. To learn more about this predicate checkout the Fulltext section on the Query Predicate Reference page.

Example Query

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

Copy
//To retreive the API object check how to query the API
api.query([
    Prismic.Predicates.at('document.type', 'blog-post'),
    Prismic.Predicates.fulltext('document', 'prismic')
]).then(function(blogPosts) {
    // blogPosts is the response object, blogPosts.results holds the documents
});