4

My Rails project implements the ElasticSearch using the Tire gem. I would like to find records with similar text in a field called description. I would like to order results based on how similar the record is (%).

Example of a similar tekst: 1. Hi my name is Tom and I like cars. 2. Hey I'm Tom. I like cars. 3. Tommy like to play with cars.

Please help me configure the model. What should I do? Thanks.

xpepermint
  • 35,055
  • 30
  • 109
  • 163

1 Answers1

5

In Elasticsearch, you can use the "more like this" API, to find similar documents.

In Tire, you can use the more_like_this query, passing it the text. See the test case for documentation.

karmi
  • 14,059
  • 3
  • 33
  • 41
  • Is there anyway to pass in a document ID versus text for more like this queries? – Henley Sep 11 '13 at 15:09
  • It is possible to query a document in elasticsearch for mlt but in tire isn't it a search with an mlt query in? The latter doesn't support specifying a document id. – Shadwell Sep 13 '13 at 10:09