Commit 9955fbe30e5326506d4d7c5b8554172b6ffa1758
1 parent
db7ad8ea
Exists in
master
and in
21 other branches
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,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 | when :not # not equal | 509 | when :not # not equal |
508 | filters << {not: term_filters(field, op_value)} | 510 | filters << {not: term_filters(field, op_value)} |
509 | when :all | 511 | when :all |
test/sql_test.rb
@@ -98,6 +98,11 @@ class TestSql < Minitest::Test | @@ -98,6 +98,11 @@ class TestSql < Minitest::Test | ||
98 | assert_search "*", ["Product A"], where: {name: /Pro.+/} | 98 | assert_search "*", ["Product A"], where: {name: /Pro.+/} |
99 | end | 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 | def test_where_string | 106 | def test_where_string |
102 | store [ | 107 | store [ |
103 | {name: "Product A", color: "RED"} | 108 | {name: "Product A", color: "RED"} |