mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 21:18:31 +00:00
By default More Like This API excludes the queried document from the response. However, when debugging or when comparing scores across different queries, it could be useful to have the best possible matched hit. So this option lets users explicitly specify the desired behavior. Closes #6067
33 lines
1.3 KiB
Plaintext
33 lines
1.3 KiB
Plaintext
[[search-more-like-this]]
|
|
== More Like This API
|
|
|
|
The more like this (mlt) API allows to get documents that are "like" a
|
|
specified document. Here is an example:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
$ curl -XGET 'http://localhost:9200/twitter/tweet/1/_mlt?mlt_fields=tag,content&min_doc_freq=1'
|
|
--------------------------------------------------
|
|
|
|
The API simply results in executing a search request with
|
|
<<query-dsl-mlt-query,moreLikeThis>> query (http
|
|
parameters match the parameters to the `more_like_this` query). This
|
|
means that the body of the request can optionally include all the
|
|
request body options in the <<search-search,search
|
|
API>> (aggs, from/to and so on). Internally, the more like this
|
|
API is equivalent to performing a boolean query of `more_like_this_field`
|
|
queries, with one query per specified `mlt_fields`.
|
|
|
|
Rest parameters relating to search are also allowed, including
|
|
`search_type`, `search_indices`, `search_types`, `search_scroll`,
|
|
`search_size` and `search_from`.
|
|
|
|
When no `mlt_fields` are specified, all the fields of the document will
|
|
be used in the `more_like_this` query generated.
|
|
|
|
By default, the queried document is excluded from the response (`include`
|
|
set to false).
|
|
|
|
Note: In order to use the `mlt` feature a `mlt_field` needs to be either
|
|
be `stored`, store `term_vector` or `source` needs to be enabled.
|