Skip to content

Commit da5788f

Browse files
MothOnMarspicandocodigo
authored andcommitted
add minimum_should_match option to bool filters
1 parent f54c470 commit da5788f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/elasticsearch/dsl/search/filters/bool.rb

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ module Filters
5757
class Bool
5858
include BaseComponent
5959

60+
option_method :minimum_should_match
61+
6062
def must(*args, &block)
6163
@hash[name][:must] ||= []
6264
value = args.empty? ? Filter.new(*args, &block).to_hash : args.first.to_hash

spec/elasticsearch/dsl/search/filters/bool_spec.rb

+14
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@
146146
end
147147
end
148148

149+
context 'when options methods are called' do
150+
151+
describe '#minimum_should_match' do
152+
153+
before do
154+
search.minimum_should_match 1
155+
end
156+
157+
it 'applies the option' do
158+
expect(search.to_hash).to eq(bool: { minimum_should_match: 1 })
159+
end
160+
end
161+
end
162+
149163
describe '#must' do
150164

151165
before do

0 commit comments

Comments
 (0)