@@ -406,7 +406,7 @@ def initialize
406406
407407 # @return [Hash<Symbol, #to_json>]
408408 def to_h
409- raise ArgumentError , "either start_time or end_time must be set for DateRangeQuery" if @start_time . nil? && @end_time . nil?
409+ raise Error :: InvalidArgument , "either start_time or end_time must be set for DateRangeQuery" if @start_time . nil? && @end_time . nil?
410410
411411 data = { }
412412 data [ :boost ] = boost if boost
@@ -483,7 +483,7 @@ def initialize
483483
484484 # @return [Hash<Symbol, #to_json>]
485485 def to_h
486- raise ArgumentError , "either min or max must be set for NumericRangeQuery" if @min . nil? && @max . nil?
486+ raise Error :: InvalidArgument , "either min or max must be set for NumericRangeQuery" if @min . nil? && @max . nil?
487487
488488 data = { }
489489 data [ :boost ] = boost if boost
@@ -551,7 +551,7 @@ def initialize
551551
552552 # @return [Hash<Symbol, #to_json>]
553553 def to_h
554- raise ArgumentError , "either min or max must be set for TermRangeQuery" if @min . nil? && @max . nil?
554+ raise Error :: InvalidArgument , "either min or max must be set for TermRangeQuery" if @min . nil? && @max . nil?
555555
556556 data = { }
557557 data [ :boost ] = boost if boost
@@ -754,7 +754,7 @@ def empty?
754754
755755 # @return [Hash<Symbol, #to_json>]
756756 def to_h
757- raise ArgumentError , "compound conjunction query must have sub-queries" if @queries . nil? || @queries . empty?
757+ raise Error :: InvalidArgument , "compound conjunction query must have sub-queries" if @queries . nil? || @queries . empty?
758758
759759 data = { :conjuncts => @queries . uniq . map ( &:to_h ) }
760760 data [ :boost ] = boost if boost
@@ -799,11 +799,11 @@ def empty?
799799
800800 # @return [Hash<Symbol, #to_json>]
801801 def to_h
802- raise ArgumentError , "compound disjunction query must have sub-queries" if @queries . nil? || @queries . empty?
802+ raise Error :: InvalidArgument , "compound disjunction query must have sub-queries" if @queries . nil? || @queries . empty?
803803
804804 data = { :disjuncts => @queries . uniq . map ( &:to_h ) }
805805 if min
806- raise ArgumentError , "disjunction query has fewer sub-queries than configured minimum" if @queries . size < min
806+ raise Error :: InvalidArgument , "disjunction query has fewer sub-queries than configured minimum" if @queries . size < min
807807
808808 data [ :min ] = min
809809 end
@@ -828,7 +828,7 @@ class BooleanQuery < SearchQuery
828828
829829 # @yieldparam [BooleanQuery] self
830830 def initialize
831- super ( )
831+ super
832832 @must = ConjunctionQuery . new
833833 @must_not = DisjunctionQuery . new
834834 @should = DisjunctionQuery . new
@@ -861,7 +861,10 @@ def should(*queries)
861861
862862 # @return [Hash<Symbol, #to_json>]
863863 def to_h
864- raise ArgumentError , "BooleanQuery must have at least one non-empty sub-query" if @must . empty? && @must_not . empty? && @should . empty?
864+ if @must . empty? && @must_not . empty? && @should . empty?
865+ raise Error ::InvalidArgument ,
866+ "BooleanQuery must have at least one non-empty sub-query"
867+ end
865868
866869 data = { }
867870 data [ :must ] = @must . to_h unless @must . empty?
@@ -1007,7 +1010,7 @@ def self.match_all(&block)
10071010 class MatchAllQuery < SearchQuery
10081011 # @yieldparam [MatchAllQuery] self
10091012 def initialize
1010- super ( )
1013+ super
10111014 yield self if block_given?
10121015 end
10131016
@@ -1030,7 +1033,7 @@ def self.match_none(&block)
10301033 class MatchNoneQuery < SearchQuery
10311034 # @yieldparam [MatchNoneQuery] self
10321035 def initialize
1033- super ( )
1036+ super
10341037 yield self if block_given?
10351038 end
10361039
0 commit comments