How does Prismic work out "Similar content"?

I’m trying to get a “Related posts” section working but the similar content query never pulls anything back. What qualifies as “similar”?

Hi @mattlaw, I don’t know all the specifics, but my understanding is that the ‘similar’ predicate will compare all the text in a document with all the other documents. It will return documents that have similar key words. It will compare text that it finds in Rich Text and Key Text fields.

When using it, you need to specify the ID of the document in question and a comparison threshold value:

Prismic.Predicates.similar( id, value )

The comparison value is an integer which is the maximum number of documents that a term may appear in to still be considered relevant. This means that the lower the value, the more picky you want to be, and you will receive less results. The higher the value, the less picky you are, and you will retrieve more matches.

So in your case I’m guessing that your search is too restrictive and I would try to increase the comparison value until you start getting the number of matches you’re looking for.

For anyone reading, you can find the documentation for the ‘similar’ predicate here:
https://prismic.io/docs/javascript/query-the-api/query-predicates-reference#59_0-similar