Class: Elasticsearch::DSL::Search::Filters::Bool
- Inherits:
-
Object
- Object
- Elasticsearch::DSL::Search::Filters::Bool
- Includes:
- BaseComponent
- Defined in:
- lib/elasticsearch/dsl/search/filters/bool.rb
Overview
A compound filter which matches documents based on combinations of filters
See the integration test for a working example.
Instance Method Summary collapse
- #must(*args, &block) ⇒ Object
- #must_not(*args, &block) ⇒ Object
- #should(*args, &block) ⇒ Object
- #to_hash ⇒ Object
Methods included from BaseComponent
Instance Method Details
#must(*args, &block) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/elasticsearch/dsl/search/filters/bool.rb', line 43 def must(*args, &block) @hash[name][:must] ||= [] value = Filter.new(*args, &block).to_hash @hash[name][:must].push(value).flatten! unless @hash[name][:must].include?(value) self end |
#must_not(*args, &block) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/elasticsearch/dsl/search/filters/bool.rb', line 50 def must_not(*args, &block) @hash[name][:must_not] ||= [] value = Filter.new(*args, &block).to_hash @hash[name][:must_not].push(value).flatten! unless @hash[name][:must_not].include?(value) self end |
#should(*args, &block) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/elasticsearch/dsl/search/filters/bool.rb', line 57 def should(*args, &block) @hash[name][:should] ||= [] value = Filter.new(*args, &block).to_hash @hash[name][:should].push(value).flatten! unless @hash[name][:should].include?(value) self end |
#to_hash ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/elasticsearch/dsl/search/filters/bool.rb', line 64 def to_hash @hash[name].update(@args.to_hash) if @args.respond_to?(:to_hash) if @block call else @hash[name] = @args unless @args.nil? || @args.empty? end @hash end |