Skip to content

Commit

Permalink
Add documentation for MoreLikeThis
Browse files Browse the repository at this point in the history
  • Loading branch information
eamonnmag committed Aug 10, 2020
1 parent dec56c3 commit 6f1b20a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion docs/search_dsl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ to directly construct the combined query:
Filters
~~~~~~~


If you want to add a query in a `filter context
<https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-filter-context.html>`_
you can use the ``filter()`` method to make things easier:
Expand Down Expand Up @@ -435,6 +434,32 @@ should be one of ``term``, ``phrase`` or ``completion`` to indicate which type
of suggester should be used.



More Like This Query
~~~~~~~~~~~~~~~~~~~~

To use Elasticsearch's more_like_this functionality, you can use the MoreLikeThis query type.

A simple example is below

.. code:: python
from elasticsearch_dsl.query import MoreLikeThis
from elasticsearch_dsl Search
my_text = 'I want to find something similar'
s = Search()
# We're going to match based only on two fields, in this case text and title
s = s.query(MoreLikeThis(like=my_text, fields=['text', 'title]))
# You can also exclude fields from the result to make the response quicker in the normal way
s = s.source(exclude=["text"])
response = s.execute()
for hit in response:
print(hit.title)
Extra properties and parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 6f1b20a

Please sign in to comment.