Class: Eson::Search::Boosting

Inherits:
Object
  • Object
show all
Includes:
Query
Defined in:
lib/eson/search/boosting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Query

included, #method_missing

Constructor Details

#initialize(options = {}) ⇒ Boosting

Returns a new instance of Boosting.



12
13
14
# File 'lib/eson/search/boosting.rb', line 12

def initialize(options = {})
  self.options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Eson::Search::Query

Instance Attribute Details

#conditionsObject

Returns the value of attribute conditions.



10
11
12
# File 'lib/eson/search/boosting.rb', line 10

def conditions
  @conditions
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/eson/search/boosting.rb', line 10

def options
  @options
end

Instance Method Details

#boosting { ... } ⇒ self

Generates a ‘boosting` query in a query context.

Yields:

  • the block containing further options and subqueries

Returns:

  • (self)

    the generated facet



8
# File 'lib/eson/search/boosting.rb', line 8

short_name :boosting

#boostsObject



16
17
18
# File 'lib/eson/search/boosting.rb', line 16

def boosts
  @boosts ||= {}
end

#negative(&block) ⇒ Object



25
26
27
28
# File 'lib/eson/search/boosting.rb', line 25

def negative(&block)
  q = (boosts[:negative] ||= SubQuery.new(args))
  q.query(&block)
end

#positive(&block) ⇒ Object



20
21
22
23
# File 'lib/eson/search/boosting.rb', line 20

def positive(&block)
  q = (boosts[:positive] ||= SubQuery.new(args))
  q.query(&block)
end

#to_query_hashObject



30
31
32
33
34
35
36
37
38
# File 'lib/eson/search/boosting.rb', line 30

def to_query_hash
  result = {}

  boosts.each do |k,v|
    result[k] = v.to_query_hash
  end

  {name => result.merge(options)}
end