Commit 9955fbe30e5326506d4d7c5b8554172b6ffa1758

Authored by Rajesh Kumar
1 parent db7ad8ea

Add alternate support for regexp queries without using a regexp ruby object

Showing 2 changed files with 7 additions and 0 deletions   Show diff stats
lib/searchkick/query.rb
... ... @@ -504,6 +504,8 @@ module Searchkick
504 504 }
505 505 }
506 506 }
  507 + when :regexp # support for regexp queries without using a regexp ruby object
  508 + filters << {regexp: {field => {value: op_value}}}
507 509 when :not # not equal
508 510 filters << {not: term_filters(field, op_value)}
509 511 when :all
... ...
test/sql_test.rb
... ... @@ -98,6 +98,11 @@ class TestSql &lt; Minitest::Test
98 98 assert_search "*", ["Product A"], where: {name: /Pro.+/}
99 99 end
100 100  
  101 + def test_alternate_regexp
  102 + store_names ["Product A", "Item B"]
  103 + assert_search "*", ["Product A"], where: {name: {regexp: "Pro.+"}}
  104 + end
  105 +
101 106 def test_where_string
102 107 store [
103 108 {name: "Product A", color: "RED"}
... ...