Module: Boolminot::Clauses::Base::InstanceMethods

Instance Method Summary collapse

Instance Method Details

#satisfied_by?(document) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NoMethodError)


11
12
13
# File 'lib/boolminot/clauses/base.rb', line 11

def satisfied_by?(document)
  raise NoMethodError, 'Sorry; Boolminot clauses do not act as percolators'
end

#to_elasticsearch(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/boolminot/clauses/base.rb', line 15

def to_elasticsearch(options = {})
  default_options = {
    context: :filter
  }
  options = default_options.merge(options)

  send "to_elasticsearch_in_#{options[:context]}_context"
end

#to_elasticsearch_negated(options = {}) ⇒ Object



24
25
26
# File 'lib/boolminot/clauses/base.rb', line 24

def to_elasticsearch_negated(options = {})
  { bool: { must_not: [to_elasticsearch(options)] } }
end

#to_raw_bool(options = {}) ⇒ Object



28
29
30
# File 'lib/boolminot/clauses/base.rb', line 28

def to_raw_bool(options = {})
  { bool: { must: [to_elasticsearch(options)] } }
end