Programming

Elasticsearch “More like this” example

Elasticsearch is an amazing tool but the documentation does not always give that much help and advice on how to get going with it. Today was more_like_this (or mlt for sure) day so I thought I’d give a “get going” example.  It isn’t that complex except that the default settings are likely to return no results if you have a small data set. That’s why here I have the minimum values turned down to one, so that if there is any match you will get some results. Once you know you have a working query you can then start to turn the requirements back up or to the defaults.

{
  "query" : {
    "more_like_this" : {
      "like_text" : "testing",
      "min_term_freq" : 1,
      "min_doc_freq" : 1
    }
  }
}
Standard

3 thoughts on “Elasticsearch “More like this” example

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s