---
title: More Like This
---

## Basic Usage

Finds documents similar to a given document or set of field values. This is useful for recommendation engines or finding related content based on textual similarities.

You must pass either:

- `document_id`, which takes a [key_field](/documentation/indexing/create_index#choosing-a-key-field) value to match against the corresponding document.
- `document_fields`, which takes a JSON object string to match against.

All other parameters are compatible with both `document_id` and `document_fields`.

<CodeGroup>
```sql Function Syntax
-- document_id
SELECT description, rating, category
FROM mock_items
WHERE id @@@ pdb.more_like_this(
  key_value => 3,
  min_term_frequency => 1
);

-- document_fields
SELECT description, rating, category
FROM mock_items
WHERE id @@@ pdb.more_like_this(
document => '{"description": "shoes"}',
min_doc_frequency => 0,
max_doc_frequency => 100,
min_term_frequency => 1
);

````
```sql JSON Syntax
-- key_value
SELECT description, rating, category
FROM mock_items
WHERE id @@@
'{
    "more_like_this": {
        "key_value": 3,
        "min_term_frequency": 1
    }
}'::jsonb;

-- document
SELECT description, rating, category
FROM mock_items
WHERE id @@@
'{
    "more_like_this": {
        "document": [["description", "shoes"]],
        "min_doc_frequency": 0,
        "max_doc_frequency": 100,
        "min_term_frequency": 1
    }
}'::jsonb;
````

</CodeGroup>

<div className="mt-8" />

<ParamField body="document_id">
  The ID of the document to find similar documents to.
</ParamField>
<ParamField body="document_fields">
  A JSON object representing the field values to use for similarity matching.
</ParamField>
<ParamField body="min_doc_frequency">
  Minimum document frequency of terms to be considered.
</ParamField>
<ParamField body="max_doc_frequency">
  Maximum document frequency of terms to be considered.
</ParamField>
<ParamField body="min_term_frequency">
  Minimum term frequency of terms to be considered.
</ParamField>
<ParamField body="max_query_terms">
  Maximum number of query terms to be used.
</ParamField>
<ParamField body="min_word_length">
  Minimum word length of terms to be considered.
</ParamField>
<ParamField body="max_word_length">
  Maximum word length of terms to be considered.
</ParamField>
<ParamField body="boost_factor">
  Boost factor to amplify the impact of matching terms.
</ParamField>
<ParamField body="stop_words">
  A JSON array of stop words to be ignored in the query.
</ParamField>
