@@ -22,17 +22,17 @@ def build
22
22
when :does_not_equal , :ne , :not_eq
23
23
@relation = relation . where ( field . to_sym . ne => value )
24
24
when :contains , :like , :matches
25
- @relation = relation . where ( field => /#{ value } / )
25
+ @relation = relation . where ( field => /#{ value } /i )
26
26
when :does_not_contain , :nlike , :not_matches
27
- @relation = relation . where ( field . to_sym . not => /#{ value } / )
27
+ @relation = relation . where ( field . to_sym . not => /#{ value } /i )
28
28
when :starts_with , :sw
29
- @relation = relation . where ( field . to_sym => /\A #{ Regexp . quote ( value ) } / )
29
+ @relation = relation . where ( field . to_sym => /\A #{ Regexp . quote ( value ) } /i )
30
30
when :does_not_start_with , :dnsw
31
- @relation = relation . where ( field . to_sym . not => /\A #{ Regexp . quote ( value ) } / )
31
+ @relation = relation . where ( field . to_sym . not => /\A #{ Regexp . quote ( value ) } /i )
32
32
when :ends_with , :ew
33
- @relation = relation . where ( field . to_sym => /#{ Regexp . quote ( value ) } \z / )
33
+ @relation = relation . where ( field . to_sym => /#{ Regexp . quote ( value ) } \z /i )
34
34
when :does_not_end_with , :dnew
35
- @relation = relation . where ( field . to_sym . not => /#{ Regexp . quote ( value ) } \z / )
35
+ @relation = relation . where ( field . to_sym . not => /#{ Regexp . quote ( value ) } \z /i )
36
36
when :greater_than , :gt
37
37
@relation = relation . where ( field . to_sym . gt => value )
38
38
when :less_than , :lt
@@ -92,9 +92,7 @@ def method_missing name, *args, &block
92
92
end
93
93
94
94
def metasearch_regexp
95
- # field_names = klass.content_columns.map(&:name)
96
95
field_names = klass . fields . map ( &:second ) . map ( &:name )
97
-
98
96
conditions = MetaSearch ::DEFAULT_WHERES . map { |condition | condition [ 0 ...-1 ] } # pop tail options
99
97
100
98
/\A (#{ field_names . join ( '|' ) } )_(#{ conditions . join ( '|' ) } )\z /
@@ -109,10 +107,7 @@ module ClassMethods
109
107
def metasearch ( params = nil , options = nil )
110
108
options ||= { }
111
109
params ||= { }
112
- MongoidSearchBuilder . new ( self , params , options ) . build
113
- # @metasearch_query
114
- # raise [params, options].inspect unless [options, params].all?(&:empty?)
115
- # scoped
110
+ MongoidSearchBuilder . new ( criteria , params , options ) . build
116
111
end
117
112
alias_method :search , :metasearch unless respond_to? ( :search )
118
113
end
0 commit comments