---
title: "Using MoreLikeThis"
url: "https://docs.ravendb.net/6.2/client-api/session/querying/how-to-use-morelikethis"
version: "6.2"
language: "python"
---

# Using MoreLikeThis

> Client language: Python. Also available for [C#](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-use-morelikethis.md), [Java](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-use-morelikethis.java.md), [PHP](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-use-morelikethis.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-use-morelikethis.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

`more_like_this` is available through query methods, and will return similar documents according
to the provided criteria and options.

## Syntax

```python
def more_like_this(
  self, more_like_this_or_builder: Union[MoreLikeThisBase, Callable[[MoreLikeThisBuilder[_T]], None]]
) -> DocumentQuery[_T]: ...
```

| `more_like_this_or_builder` parameter | Description |
| - | - |
| `MoreLikeThisBase` | Defines the type of MoreLikeThis that should be executed |
| `Callable[[MoreLikeThisBuilder[_T]], None]]` | Builder with fluent API that constructs the `MoreLikeThisBase` instance |

### Builder

```python
def using_any_document(self) -> MoreLikeThisOperations[_T]: ...

def using_document(
  self, document_json_or_builder: Union[str, Callable[[DocumentQuery[_T]], None]]
) -> MoreLikeThisOperations[_T]: ...

def with_options(self, options: MoreLikeThisOptions) -> MoreLikeThisOperations[_T]: ...
```

| Builder method | Parameter | Type | Description |
| - | - | - | - |
| **using\_any\_document** | | | |
| **using\_document** | `document_json_or_builder` (Union) | `str` | Inline JSON document that will be used for the operation |
| **using\_document** | `document_json_or_builder` (Union) | `Callable[[DocumentQuery[_T]], None]` | Filtering expression to find a document that will be used for the operation |
| **with\_options** | `options` | `MoreLikeThisOptions` | Non-default options to be used by the operation |

### Options

```python
def __init__(
  self,
  minimum_term_frequency: int = None,
  maximum_query_terms: int = None,
  maximum_number_of_tokens_parsed: int = None,
  minimum_word_length: int = None,
  maximum_word_length: int = None,
  minimum_document_frequency: int = None,
  maximum_document_frequency: int = None,
  maximum_document_frequency_percentage: int = None,
  boost: bool = None,
  boost_factor: float = None,
  stop_words_document_id: str = None,
  fields: List[str] = None,
): ...
```

| Options | | |
| - | - | - |
| **minimum\_term\_frequency** | int | Ignores terms with less than this frequency in the source doc |
| **maximum\_query\_terms** | int | Returns a query with no more than this many terms |
| **maximum\_number\_of\_tokens\_parsed** | int | The maximum number of tokens to parse in each example doc field that is not stored with TermVector support |
| **minimum\_word\_length** | int | Ignores words less than this length or, if 0, then this has no effect |
| **maximum\_word\_length** | int | Ignores words greater than this length or if 0 then this has no effect |
| **minimum\_document\_frequency** | int | Ignores words which do not occur in at least this many documents |
| **maximum\_document\_frequency** | int | Ignores words which occur in more than this many documents |
| **maximum\_document\_frequency\_percentage** | int | Ignores words which occur in more than this percentage of documents |
| **boost** | bool | Boost terms in query based on score |
| **boost\_factor** | float | Boost factor when boosting based on score |
| **stop\_words\_document\_id** | str | Document ID containing custom stop words |
| **Fields** | List\[str] | Fields to compare |

## Example I

### Query

```python
# Search for similar articles to 'articles/1'
# using 'Articles/MoreLikeThis' index and search only field 'body'
articles = list(
  session.query_index_type(Articles_MoreLikeThis, Article).more_like_this(
      lambda builder: builder.using_document(
          lambda x: x.where_equals("Id", "articles/1")
      ).with_options(MoreLikeThisOptions(fields=["body"]))
  )
)
```

### RQL

```sql
from index 'Articles/MoreLikeThis' 
where morelikethis(id() = 'articles/1', '{ "Fields" : [ "Body" ] }')
```

## Example II

### Query

```python
# Search for similar articles to 'articles/1'
# using 'Articles/MoreLikeThis' index and search only field 'body'
# where article category is 'IT'
articles = list(
  session.query_index_type(Articles_MoreLikeThis, Article)
  .more_like_this(
      lambda builder: builder.using_document(
          lambda x: x.where_equals("Id", "articles/1")
      ).with_options(MoreLikeThisOptions(fields=["body"]))
  )
  .where_equals("category", "IT")
)
```

### RQL

```sql
from index 'Articles/MoreLikeThis' 
where morelikethis(id() = 'articles/1', '{ "Fields" : [ "Body" ] }') and Category == 'IT'
```

## See also

- [How to Query](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-query.python.md)
- [MoreLikeThis](https://docs.ravendb.net/6.2/indexes/querying/morelikethis.python.md)
