Module: Litesearch::Model::InstanceMethods
- Defined in:
- lib/litestack/litesearch/model.rb
Instance Method Summary collapse
Instance Method Details
#similar(limit = 10) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/litestack/litesearch/model.rb', line 25 def similar(limit = 10) conn = self.class.get_connection idx = conn.search_index(self.class.send(:index_name)) r_a_h = conn.results_as_hash conn.results_as_hash = true rs = idx.similar(id, limit) conn.results_as_hash = r_a_h result = [] rs.each do |row| obj = self.class.fetch_row(row["id"]) obj.search_rank = row["search_rank"] result << obj end result end |