searchkick 4.2.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa81f3f42b5f2e83d3db17aba5e43c84d49966d2ef132d285d843c0a81e3b252
4
- data.tar.gz: 9cb2777b0ad6c6f328e99b6292f4253c113772d8b15b28d6bc013949f5375a44
3
+ metadata.gz: 964d3c57721433fff2893d53c0dd91b60e66f0e0b75c560e71430bc955fac9cb
4
+ data.tar.gz: 02643d50655602ca36ef006f9f68031b185bcc169a739db0769a7921ba00677f
5
5
  SHA512:
6
- metadata.gz: 77bd3f87f47c97a2ed6c76854ac148cfb350f6cff97cf5158e29dec2a9812f262633561da245f6c495931e9070f36b9c15e8fec24e89380071a8548109cb2b24
7
- data.tar.gz: ace8f56a6506eb6c6ba0f05562978d91d619839e34d840ecb1af72d666fa1e86d46fe4528e868218ce731292b91df4602defad88fc79d36e8f22cd7c6dc20178
6
+ metadata.gz: d5d39a9d775e2beac62552cc498447ffd28d71c8f3ddeee6e6a9cb809b07d3a6c50d66d720bfd335d5b349af75f046ccbf4d5fc4cb4e6a0a27ccebaa8cc46daf
7
+ data.tar.gz: 6a3d30a7d90c7119c4bde98acba3ffc42579524e4ab7a2dbafb2865013d68928d18c2773d17253b42e85ad785c56525203f6843661e78210645fad6dd355ba85
@@ -1,3 +1,8 @@
1
+ ## 4.3.0 (2020-02-19)
2
+
3
+ - Fixed `like` queries with `"` character
4
+ - Better error when invalid parameters passed to `where`
5
+
1
6
  ## 4.2.1 (2020-01-27)
2
7
 
3
8
  - Fixed deprecation warnings with Elasticsearch
@@ -4,7 +4,7 @@ First, thanks for wanting to contribute. You’re awesome! :heart:
4
4
 
5
5
  ## Help
6
6
 
7
- We’re not able to provide support through GitHub Issues. If you’re looking for help with your code, try posting on [Stack Overflow](https://stackoverflow.com/).
7
+ We’re not able to provide support through GitHub Issues. If you’re looking for help with your code, try posting on [Stack Overflow](https://stackoverflow.com/questions/tagged/searchkick).
8
8
 
9
9
  All features should be documented. If you don’t see a feature in the docs, assume it doesn’t exist.
10
10
 
data/README.md CHANGED
@@ -137,7 +137,7 @@ Select
137
137
  select: [:name]
138
138
  ```
139
139
 
140
- [These source filtering options are supported](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html)
140
+ [These source filtering options are supported](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-source-filtering)
141
141
 
142
142
  ### Results
143
143
 
@@ -184,6 +184,7 @@ module Searchkick
184
184
 
185
185
  def reindex(relation, method_name, scoped:, full: false, scope: nil, **options)
186
186
  refresh = options.fetch(:refresh, !scoped)
187
+ options.delete(:refresh)
187
188
 
188
189
  if method_name
189
190
  # update
@@ -871,6 +871,11 @@ module Searchkick
871
871
  end
872
872
 
873
873
  def where_filters(where)
874
+ # if where.respond_to?(:permitted?) && !where.permitted?
875
+ # # TODO check in more places
876
+ # Searchkick.warn("Passing unpermitted parameters will raise an exception in Searchkick 5")
877
+ # end
878
+
874
879
  filters = []
875
880
  (where || {}).each do |field, value|
876
881
  field = :_id if field.to_s == "id"
@@ -953,10 +958,17 @@ module Searchkick
953
958
  # % matches zero or more characters
954
959
  # _ matches one character
955
960
  # \ is escape character
956
- regex = Regexp.escape(op_value).gsub(/(?<!\\)%/, ".*").gsub(/(?<!\\)_/, ".").gsub("\\%", "%").gsub("\\_", "_")
961
+ # escape Lucene reserved characters
962
+ # https://www.elastic.co/guide/en/elasticsearch/reference/current/regexp-syntax.html#regexp-optional-operators
963
+ reserved = %w(. ? + * | { } [ ] ( ) " \\)
964
+ regex = op_value.dup
965
+ reserved.each do |v|
966
+ regex.gsub!(v, "\\" + v)
967
+ end
968
+ regex = regex.gsub(/(?<!\\)%/, ".*").gsub(/(?<!\\)_/, ".").gsub("\\%", "%").gsub("\\_", "_")
957
969
  filters << {regexp: {field => {value: regex}}}
958
970
  when :prefix
959
- filters << {prefix: {field => op_value}}
971
+ filters << {prefix: {field => {value: op_value}}}
960
972
  when :regexp # support for regexp queries without using a regexp ruby object
961
973
  filters << {regexp: {field => {value: op_value}}}
962
974
  when :not, :_not # not equal
@@ -1036,7 +1048,16 @@ module Searchkick
1036
1048
 
1037
1049
  {regexp: {field => {value: source, flags: "NONE"}}}
1038
1050
  else
1039
- {term: {field => value}}
1051
+ # TODO add this for other values
1052
+ if value.as_json.is_a?(Enumerable)
1053
+ # query will fail, but this is better
1054
+ # same message as Active Record
1055
+ # TODO make TypeError
1056
+ # raise InvalidQueryError for backward compatibility
1057
+ raise Searchkick::InvalidQueryError, "can't cast #{value.class.name}"
1058
+ end
1059
+
1060
+ {term: {field => {value: value}}}
1040
1061
  end
1041
1062
  end
1042
1063
 
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "4.2.1"
2
+ VERSION = "4.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchkick
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-28 00:00:00.000000000 Z
11
+ date: 2020-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel