Module: Caoutsearch::Search::Adapter::ActiveRecord::Relation
- Defined in:
- lib/caoutsearch/search/adapter/active_record.rb
Instance Attribute Summary collapse
-
#hits ⇒ Object
Returns the value of attribute hits.
Instance Method Summary collapse
-
#records ⇒ Object
Re-order records based on hits order.
Instance Attribute Details
#hits ⇒ Object
Returns the value of attribute hits.
17 18 19 |
# File 'lib/caoutsearch/search/adapter/active_record.rb', line 17 def hits @hits end |
Instance Method Details
#records ⇒ Object
Re-order records based on hits order
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/caoutsearch/search/adapter/active_record.rb', line 25 def records return super if order_values.present? || @_reordered_records load indexes = @hits.each_with_index.to_h { |hit, index| [hit["_id"].to_s, index] } @records = @records.sort_by { |record| indexes[record.id.to_s] }.freeze @_reordered_records = true @records end |