Class: Eson::Search::Fuzzy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Query

included, #method_missing

Constructor Details

#initialize(*args) ⇒ Fuzzy

Returns a new instance of Fuzzy.



12
13
14
15
16
17
18
# File 'lib/eson/search/fuzzy.rb', line 12

def initialize(*args)
  if args.length == 1
    self.options = args.first
  else
    self.field = QueryField.new(*args)
  end
end

Dynamic Method Handling

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

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



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

def field
  @field
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#fuzzy { ... } ⇒ self

Generates a ‘fuzzy` query in a query context.

Yields:

  • the block containing further options and subqueries

Returns:

  • (self)

    the generated facet



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

short_name :fuzzy

#to_query_hashObject



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

def to_query_hash
  if field
    {name => field.to_query_hash}
  else
    {name => options}
  end
end