Commit 6664a9ea3fc8bf70210937bfd619666672bde220

Authored by Andrew
1 parent 9ddaf369

Only use standard operators for Ruby regexp - #1117

Showing 2 changed files with 6 additions and 1 deletions   Show diff stats
lib/searchkick/query.rb
... ... @@ -900,7 +900,7 @@ module Searchkick
900 900 elsif value.nil?
901 901 {bool: {must_not: {exists: {field: field}}}}
902 902 elsif value.is_a?(Regexp)
903   - {regexp: {field => {value: value.source}}}
  903 + {regexp: {field => {value: value.source, flags: "NONE"}}}
904 904 else
905 905 {term: {field => value}}
906 906 end
... ...
test/where_test.rb
... ... @@ -79,6 +79,11 @@ class WhereTest < Minitest::Test
79 79 assert_search "*", ["Product A"], where: {name: {regexp: "Pro.+"}}
80 80 end
81 81  
  82 + def test_special_regexp
  83 + store_names ["Product <A>", "Item <B>"]
  84 + assert_search "*", ["Product <A>"], where: {name: /Pro.+<.+/}
  85 + end
  86 +
82 87 def test_where_string
83 88 store [
84 89 {name: "Product A", color: "RED"}
... ...