Class: Eson::Search::Indices

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Query

included, #method_missing

Constructor Details

#initialize(*indices) ⇒ Indices

Returns a new instance of Indices.



11
12
13
# File 'lib/eson/search/indices.rb', line 11

def initialize(*indices)
  self.indices = indices
end

Dynamic Method Handling

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

Instance Attribute Details

#indices { ... } ⇒ self

Generates a ‘indices` query in a query context.

Yields:

  • the block containing further options and subqueries

Returns:

  • (self)

    the generated facet



7
# File 'lib/eson/search/indices.rb', line 7

short_name :indices

#no_match_valObject

Returns the value of attribute no_match_val.



9
10
11
# File 'lib/eson/search/indices.rb', line 9

def no_match_val
  @no_match_val
end

#query_valObject

Returns the value of attribute query_val.



9
10
11
# File 'lib/eson/search/indices.rb', line 9

def query_val
  @query_val
end

Instance Method Details

#no_match_query(no_match_val = nil) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/eson/search/indices.rb', line 20

def no_match_query(no_match_val = nil)
  if no_match_val
    self.no_match_val = no_match_val
  elsif block_given?
    self.no_match_val ||= SubQuery.new(args)
    self.no_match_val.send(context, &Proc.new)
  end
end

#query(&block) ⇒ Object



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

def query(&block)
  self.query_val ||= SubQuery.new(args)
  self.query_val.send(context, &Proc.new)
end

#to_query_hashObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/eson/search/indices.rb', line 29

def to_query_hash
  options = {
    :indices => indices,
    :query => self.query_val.to_query_hash,
  }

  if no_match_val
    if no_match_val.respond_to? :to_query_hash
      no_match = no_match_val.to_query_hash
    else
      no_match = no_match_val
    end
    options.merge!(:no_match_query => no_match)
  end
  
  { name => options }
end