Class: Queries::TermQueryBuilder

Inherits:
QueryBuilder show all
Defined in:
lib/queries/term_query_builder.rb

Constant Summary collapse

NAME =
"term"

Instance Method Summary collapse

Methods inherited from QueryBuilder

#boost

Methods included from AttributesReader

#attributes

Methods included from AbstractQueryBuilder

#do_equals?, #name

Constructor Details

#initialize(field_name:, value: nil) ⇒ TermQueryBuilder

@params:

field_name: name of the field in the document which is being queried
value: is being matched to the data in that field.


16
17
18
19
# File 'lib/queries/term_query_builder.rb', line 16

def initialize field_name:, value: nil
  @field_name = field_name
  @value = value
end

Instance Method Details

#field_name_exprObject

FIELD NAME ########## returns field_name



33
34
35
# File 'lib/queries/term_query_builder.rb', line 33

def field_name_expr
  return @field_name
end

#queryObject



21
22
23
24
25
26
27
28
29
# File 'lib/queries/term_query_builder.rb', line 21

def query
  query = {}
  term_query = {}
  field_options = self.common_query
  field_options[:value] = @value
  term_query[@field_name.intern] = field_options
  query[name.intern] = term_query
  return query
end

#value_exprObject

FIELD VALUE ########## returns value



39
40
41
# File 'lib/queries/term_query_builder.rb', line 39

def value_expr
  return @value
end