class RediSearch::Search
Attributes
clauses[RW]
index[RW]
term_clause[R]
used_clauses[R]
Public Class Methods
new(index, term = nil, **term_options)
click to toggle source
# File lib/redi_search/search.rb, line 19 def initialize(index, term = nil, **term_options) @index = index @clauses = [] @used_clauses = Set.new @term_clause = term && And.new(self, term, nil, **term_options) end
Public Instance Methods
dup()
click to toggle source
# File lib/redi_search/search.rb, line 44 def dup self.class.new(index) end
explain()
click to toggle source
# File lib/redi_search/search.rb, line 38 def explain RediSearch.client.call!( "EXPLAINCLI", index.name, term_clause.to_s ).join(" ").strip end
results()
click to toggle source
# File lib/redi_search/search.rb, line 28 def results if model no_content unless loaded? model.where(id: to_a.map(&:document_id_without_index)) else to_a end end
Private Instance Methods
command()
click to toggle source
# File lib/redi_search/search.rb, line 52 def command ["SEARCH", index.name, term_clause.to_s, *clauses] end
parse_response(response)
click to toggle source
# File lib/redi_search/search.rb, line 56 def parse_response(response) @documents = Result.new(self, response[0], response[1..-1]) end
valid?()
click to toggle source
# File lib/redi_search/search.rb, line 60 def valid? !term_clause.to_s.empty? end