One of the nice features in ElasticSearch is ‘The More Like This’ Query. ‘The More Like This’ Query finds documents that are "like" a given set of documents. In order to do so, MLT selects a set of representative terms of these input documents, forms a query using these terms, executes the query and returns the results.
An example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = NuSearchConfiguration.GetClient(); | |
var result = client.Search<Document>(s => s | |
.Query(q=> | |
q.MoreLikeThis(sn => sn | |
.Name("named_query") | |
.Like(l => l | |
.Document(d => d.Id("Test")) | |
.Text("some long text") | |
)); |
The really important parameter is the Like() where you can specify free form text and/or a single or multiple documents.
More information: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html