Commit 2c49e08603b116efae0ff23aaac5e9c09dfaad67
Exists in
master
and in
21 other branches
Merge pull request #465 from meetrajesh/master
Additional support for regular expressions (using strings instead of Regexp 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 < 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"} | ... | ... |