Method: BooleanTermParser::Query#to_elasticsearch

Defined in:
lib/doing/boolean_term_parser.rb

#to_elasticsearchObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/doing/boolean_term_parser.rb', line 58

def to_elasticsearch
  query = {}

  if should_terms.any?
    query[:should] = should_terms.map do |term|
      match(term)
    end
  end

  if must_terms.any?
    query[:must] = must_terms.map do |term|
      match(term)
    end
  end

  if must_not_terms.any?
    query[:must_not] = must_not_terms.map do |term|
      match(term)
    end
  end

  query
end