4
votes

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.

1

1 Answers

5
votes

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.