searchkick 4.6.0 → 4.6.1

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: d93159910ecc579b56511b5d8c6908b34fecbce17b49ccbc264383068610feb9
4
- data.tar.gz: a60319ffc12e2aac95bf96f616bb65afcb8e75b77a89598e960193c8424c677a
3
+ metadata.gz: d1d925c63766341731235f39ccc55ff9c897927692bd36e0cfd6038a1d371d29
4
+ data.tar.gz: c3b2f3597751a87b1498919c210fb25f5f14a0514632a5e4e351d54bc799cb63
5
5
  SHA512:
6
- metadata.gz: 1ce03474756a2adf3ada602580c6e56d2a39d39d93096b9d796167f9bc841a92b5d321914a05ab75ca9e10e87cf6e77ed8590b6e9934cae1ec0e56ba590f65c8
7
- data.tar.gz: ae617b74a6ed27f6caa6bf9f3494a62d35ab4176e87bf868a5c04e60ae1b78462bee07de1f182cd3d81cac5a3bcaa22a57aad5e75f61c384aa8ceb6344822486
6
+ metadata.gz: e33b43ba33b0e832a7db8d65ffce7d83b5ca6e293b9d3049d1b8a4fee18c35a60a3353a8132e4baa5b77fca00b4d2eb383c5b4adfa8a089282befe19925aca82
7
+ data.tar.gz: 2e16bd24df683e543d81b1f272d8f67d42ef273c42de9d21f4366e001f39133161d714007aa0306077747d925c03c008f74b2b5ae5f0b4fe586daeba1aa8df66
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 4.6.1 (2021-09-25)
2
+
3
+ - Added `ilike` operator for Elasticsearch 7.10+
4
+ - Fixed missing methods with `multi_search`
5
+
1
6
  ## 4.6.0 (2021-08-22)
2
7
 
3
8
  - Added support for case-insensitive regular expressions with Elasticsearch 7.10+
data/README.md CHANGED
@@ -103,19 +103,20 @@ Where
103
103
 
104
104
  ```ruby
105
105
  where: {
106
- expires_at: {gt: Time.now}, # lt, gte, lte also available
107
- orders_count: 1..10, # equivalent to {gte: 1, lte: 10}
108
- aisle_id: [25, 30], # in
109
- store_id: {not: 2}, # not
110
- aisle_id: {not: [25, 30]}, # not in
111
- user_ids: {all: [1, 3]}, # all elements in array
112
- category: {like: "%frozen%"}, # like
113
- category: /frozen .+/, # regexp
114
- category: {prefix: "frozen"}, # prefix
115
- store_id: {exists: true}, # exists
106
+ expires_at: {gt: Time.now}, # lt, gte, lte also available
107
+ orders_count: 1..10, # equivalent to {gte: 1, lte: 10}
108
+ aisle_id: [25, 30], # in
109
+ store_id: {not: 2}, # not
110
+ aisle_id: {not: [25, 30]}, # not in
111
+ user_ids: {all: [1, 3]}, # all elements in array
112
+ category: {like: "%frozen%"}, # like
113
+ category: {ilike: "%frozen%"}, # ilike
114
+ category: /frozen .+/, # regexp
115
+ category: {prefix: "frozen"}, # prefix
116
+ store_id: {exists: true}, # exists
116
117
  _or: [{in_stock: true}, {backordered: true}],
117
118
  _and: [{in_stock: true}, {backordered: true}],
118
- _not: {store_id: 1} # negate a condition
119
+ _not: {store_id: 1} # negate a condition
119
120
  }
120
121
  ```
121
122
 
@@ -1230,7 +1231,7 @@ Searchkick uses `ENV["ELASTICSEARCH_URL"]` for the Elasticsearch server. This de
1230
1231
 
1231
1232
  - [Elastic Cloud](#elastic-cloud)
1232
1233
  - [Heroku](#heroku)
1233
- - [Amazon Elasticsearch Service](#amazon-elasticsearch-service)
1234
+ - [Amazon OpenSearch Service](#amazon-opensearch-service)
1234
1235
  - [Self-Hosted and Other](#self-hosted-and-other)
1235
1236
 
1236
1237
  ### Elastic Cloud
@@ -1290,7 +1291,7 @@ Then deploy and reindex:
1290
1291
  heroku run rake searchkick:reindex:all
1291
1292
  ```
1292
1293
 
1293
- ### Amazon Elasticsearch Service
1294
+ ### Amazon OpenSearch Service
1294
1295
 
1295
1296
  Create an initializer `config/initializers/elasticsearch.rb` with:
1296
1297
 
@@ -363,7 +363,7 @@ module Searchkick
363
363
  end
364
364
  rescue Elasticsearch::Transport::Transport::Errors::BadRequest => e
365
365
  if e.message.include?("No handler for type [text]")
366
- raise UnsupportedVersionError, "This version of Searchkick requires Elasticsearch 5 or greater"
366
+ raise UnsupportedVersionError, "This version of Searchkick requires Elasticsearch 6 or greater"
367
367
  end
368
368
 
369
369
  raise e
@@ -1,5 +1,6 @@
1
1
  module Searchkick
2
2
  class Query
3
+ include Enumerable
3
4
  extend Forwardable
4
5
 
5
6
  @@metric_aggs = [:avg, :cardinality, :max, :min, :sum]
@@ -12,7 +13,8 @@ module Searchkick
12
13
  :took, :error, :model_name, :entry_name, :total_count, :total_entries,
13
14
  :current_page, :per_page, :limit_value, :padding, :total_pages, :num_pages,
14
15
  :offset_value, :offset, :previous_page, :prev_page, :next_page, :first_page?, :last_page?,
15
- :out_of_range?, :hits, :response, :to_a, :first, :scroll
16
+ :out_of_range?, :hits, :response, :to_a, :first, :scroll, :highlights, :with_highlights,
17
+ :with_score, :misspellings?, :scroll_id, :clear_scroll, :missing_records, :with_hit
16
18
 
17
19
  def initialize(klass, term = "*", **options)
18
20
  unknown_keywords = options.keys - [:aggs, :block, :body, :body_options, :boost,
@@ -959,7 +961,7 @@ module Searchkick
959
961
  }
960
962
  }
961
963
  }
962
- when :like
964
+ when :like, :ilike
963
965
  # based on Postgres
964
966
  # https://www.postgresql.org/docs/current/functions-matching.html
965
967
  # % matches zero or more characters
@@ -973,7 +975,16 @@ module Searchkick
973
975
  regex.gsub!(v, "\\" + v)
974
976
  end
975
977
  regex = regex.gsub(/(?<!\\)%/, ".*").gsub(/(?<!\\)_/, ".").gsub("\\%", "%").gsub("\\_", "_")
976
- filters << {regexp: {field => {value: regex, flags: "NONE"}}}
978
+
979
+ if op == :ilike
980
+ if below710?
981
+ raise ArgumentError, "ilike requires Elasticsearch 7.10+"
982
+ else
983
+ filters << {regexp: {field => {value: regex, flags: "NONE", case_insensitive: true}}}
984
+ end
985
+ else
986
+ filters << {regexp: {field => {value: regex, flags: "NONE"}}}
987
+ end
977
988
  when :prefix
978
989
  filters << {prefix: {field => {value: op_value}}}
979
990
  when :regexp # support for regexp queries without using a regexp ruby object
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "4.6.0"
2
+ VERSION = "4.6.1"
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.6.0
4
+ version: 4.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-22 00:00:00.000000000 Z
11
+ date: 2021-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel