简体   繁体   中英

ElasticSearch/Tire: Find similar articles

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM