Skip to content

Commit a1df7a8

Browse files
ocowchunkarmi
authored andcommitted
[DSL] Added missing options to the bool query
Closes #357
1 parent 2af8aba commit a1df7a8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

elasticsearch-dsl/lib/elasticsearch/dsl/search/queries/bool.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ module Queries
3636
class Bool
3737
include BaseComponent
3838

39+
option_method :minimum_should_match
40+
option_method :boost
41+
3942
def must(*args, &block)
4043
@hash[name][:must] ||= []
4144
value = Query.new(*args, &block).to_hash

elasticsearch-dsl/test/unit/queries/bool_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ class BoolTest < ::Test::Unit::TestCase
2727
assert_equal( { bool: {must: [ {match: { foo: 'bar' }} ] } }, subject.to_hash )
2828
end
2929

30+
should "have option methods" do
31+
subject = Bool.new do
32+
should { term tag: 'wow' }
33+
should { term tag: 'elasticsearch' }
34+
35+
minimum_should_match 1
36+
boost 1.0
37+
end
38+
39+
assert_equal( { bool:
40+
{
41+
minimum_should_match: 1,
42+
boost: 1.0,
43+
should: [ {term: { tag: 'wow' }}, {term: { tag: 'elasticsearch' }} ]
44+
}
45+
},
46+
subject.to_hash )
47+
end
48+
3049
should "take a block with multiple methods" do
3150
subject = Bool.new do
3251
must { match foo: 'bar' }

0 commit comments

Comments
 (0)