Class: Tire::Search::ConstantScoreQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/tire/search/query.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ ConstantScoreQuery

Returns a new instance of ConstantScoreQuery.



185
186
187
188
# File 'lib/tire/search/query.rb', line 185

def initialize(&block)
  @value = {}
  block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given?
end

Instance Method Details

#boost(boost) ⇒ Object



201
202
203
# File 'lib/tire/search/query.rb', line 201

def boost(boost)
  @value.update(:boost => boost)
end

#filter(type, *options) ⇒ Object



190
191
192
193
194
195
# File 'lib/tire/search/query.rb', line 190

def filter(type, *options)
  @value[:filter] ||= {}
  @value[:filter][:and] ||= []
  @value[:filter][:and] << Filter.new(type, *options).to_hash
  @value
end

#query(&block) ⇒ Object



197
198
199
# File 'lib/tire/search/query.rb', line 197

def query(&block)
  @value.update(:query => Query.new(&block).to_hash)
end

#to_hashObject



205
206
207
# File 'lib/tire/search/query.rb', line 205

def to_hash
  @value
end