Class: Boolminot::Clauses::Compounds::Disjunction
Instance Method Summary
collapse
predicate_factory
#clauses, #to_raw_bool
#satisfied_by?, #to_elasticsearch, #to_raw_bool
Instance Method Details
#or_with_terms(terms_clause, options = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/boolminot/clauses/compounds/disjunction.rb', line 15
def or_with_terms(terms_clause, options = {})
default_options = {
argument_first: true
}
options = default_options.merge(options)
return super(terms_clause) unless terms_clause.opts.empty?
terms_clauses_with_same_field, others = clauses.partition { |q| q.terms_with_field?(terms_clause.field) }
return super(terms_clause) if terms_clauses_with_same_field.empty?
with_same_field = terms_clauses_with_same_field.first same_field = with_same_field.field
values = with_same_field.values
more_values = terms_clause.values
all_values = options[:argument_first] ? (more_values + values) : (values + more_values)
with_more_values = clause_factory.terms(same_field, all_values)
updated_clauses = options[:argument_first] ? ([with_more_values] + others) : (others + [with_more_values])
clause_factory.disjunction(updated_clauses)
end
|
#to_elasticsearch_negated(options = {}) ⇒ Object
11
12
13
|
# File 'lib/boolminot/clauses/compounds/disjunction.rb', line 11
def to_elasticsearch_negated(options = {})
{ bool: { must_not: clauses.map { |c| c.to_elasticsearch(options) } } }
end
|