Query Similar Documents

The similar argument allows you to find documents in your Prismic repository that have similar content to a given document. This allows you to build an automated content discovery feature (for example, a "Related posts" section).


The similar filter

You just need to provide the similar argument with an object containing the ID of a document and the maximum number of documents that a term may appear in to still be considered relevant.

Here is an example of how to use the similar filter:

Copy
query{
  allBlog_posts(similar:{ documentId:"W45YDyEAAD42GS9s", max:30 }){
    totalCount
    edges{
      node{
        title
        main_image
      }
    }
  }
}

The document max

The max value you need to provide above will determine how sensitive the filter is. It represents the maximum number of documents that a term may appear in to still be considered relevant.

This means that the higher the value, the more documents that will be returned. A lower maximum value will return less documents.