Class: Sensei::Query
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Operators
#&, #*, #boost!, #must_not, #|, #~
Constructor Details
#initialize(opts = {}) ⇒ Query
Returns a new instance of Query.
59
60
61
|
# File 'lib/sensei/query.rb', line 59
def initialize(opts={})
@options = opts
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
54
55
56
|
# File 'lib/sensei/query.rb', line 54
def options
@options
end
|
Class Method Details
.construct(&block) ⇒ Object
71
72
73
|
# File 'lib/sensei/query.rb', line 71
def self.construct &block
class_eval(&block)
end
|
.q(h) ⇒ Object
75
76
77
|
# File 'lib/sensei/query.rb', line 75
def self.q(h)
h.to_sensei
end
|
Instance Method Details
#get_boost ⇒ Object
63
64
65
|
# File 'lib/sensei/query.rb', line 63
def get_boost
options[:boost] ? {:boost => options[:boost]} : {}
end
|
#not_query? ⇒ Boolean
79
80
81
|
# File 'lib/sensei/query.rb', line 79
def not_query?
self.is_a?(Sensei::BoolQuery) && options[:operation] == :must_not
end
|
#run(options = {}) ⇒ Object
83
84
85
86
87
88
89
90
|
# File 'lib/sensei/query.rb', line 83
def run(options = {})
results = Sensei::Client.new(options.merge(:query => self)).search
if @@result_klass
@@result_klass.new(results)
else
results
end
end
|
#to_sensei ⇒ Object
67
68
69
|
# File 'lib/sensei/query.rb', line 67
def to_sensei
self
end
|