searchkick 4.5.2 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81a9204c559530b42163004d28daaafce96c3368ae9949a0214b3d8701003a54
4
- data.tar.gz: ba8b73a669a257eedc8f2533d7dfbbde960ad0b5b5a5cfec2d6923a127eb6df1
3
+ metadata.gz: d93159910ecc579b56511b5d8c6908b34fecbce17b49ccbc264383068610feb9
4
+ data.tar.gz: a60319ffc12e2aac95bf96f616bb65afcb8e75b77a89598e960193c8424c677a
5
5
  SHA512:
6
- metadata.gz: 1d5a878593afa54f7db54163b6e3166ecd76fe784ef28a5d0e22ae874dd1fc4ffc6743d38f27015b2b30c1f5a79c280ef326e0fd240fb51459677bd2a3f20abb
7
- data.tar.gz: 956e52c052b0ce74ada39e30425c3191878a4cc4e08c91dd8eefc37bba9a47a924481c344329efd203ca133b1ec26e1cce2673dd60603e8aec44233fae24b51e
6
+ metadata.gz: 1ce03474756a2adf3ada602580c6e56d2a39d39d93096b9d796167f9bc841a92b5d321914a05ab75ca9e10e87cf6e77ed8590b6e9934cae1ec0e56ba590f65c8
7
+ data.tar.gz: ae617b74a6ed27f6caa6bf9f3494a62d35ab4176e87bf868a5c04e60ae1b78462bee07de1f182cd3d81cac5a3bcaa22a57aad5e75f61c384aa8ceb6344822486
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 4.6.0 (2021-08-22)
2
+
3
+ - Added support for case-insensitive regular expressions with Elasticsearch 7.10+
4
+ - Added support for `OPENSEARCH_URL`
5
+ - Fixed error with `debug` option
6
+
1
7
  ## 4.5.2 (2021-08-05)
2
8
 
3
9
  - Fixed error with reindex queue
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2020 Andrew Kane
1
+ Copyright (c) 2013-2021 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -45,7 +45,7 @@ Check out [Searchjoy](https://github.com/ankane/searchjoy) for analytics and [Au
45
45
 
46
46
  ## Getting Started
47
47
 
48
- Install [Elasticsearch](https://www.elastic.co/downloads/elasticsearch) or [OpenSearch](https://opensearch.org/downloads.html) (OpenSearch support is experimental). For Homebrew, use:
48
+ Install [Elasticsearch](https://www.elastic.co/downloads/elasticsearch) or [OpenSearch](https://opensearch.org/downloads.html). For Homebrew, use:
49
49
 
50
50
  ```sh
51
51
  brew install elasticsearch # or opensearch
@@ -125,7 +125,7 @@ Order
125
125
  order: {_score: :desc} # most relevant first - default
126
126
  ```
127
127
 
128
- [All of these sort options are supported](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html)
128
+ [All of these sort options are supported](https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-search-results.html)
129
129
 
130
130
  Limit / offset
131
131
 
@@ -139,7 +139,7 @@ Select
139
139
  select: [:name]
140
140
  ```
141
141
 
142
- [These source filtering options are supported](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-source-filtering)
142
+ [These source filtering options are supported](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#source-filtering)
143
143
 
144
144
  ### Results
145
145
 
@@ -392,7 +392,7 @@ search_synonyms: "synonyms.txt"
392
392
  Add [elasticsearch-xpack](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-xpack) to your Gemfile:
393
393
 
394
394
  ```ruby
395
- gem 'elasticsearch-xpack', '>= 7.8.0'
395
+ gem 'elasticsearch-xpack', '>= 7.8', '< 7.14'
396
396
  ```
397
397
 
398
398
  And use:
@@ -401,7 +401,7 @@ And use:
401
401
  Product.search_index.reload_synonyms
402
402
  ```
403
403
 
404
- #### Elasticsearch < 7.3
404
+ #### Elasticsearch < 7.3 or OpenSearch
405
405
 
406
406
  You can use a library like [ActsAsTaggableOn](https://github.com/mbleigh/acts-as-taggable-on) and do:
407
407
 
@@ -899,7 +899,7 @@ Additional options can be specified for each field:
899
899
  Band.search "cinema", fields: [:name], highlight: {fields: {name: {fragment_size: 200}}}
900
900
  ```
901
901
 
902
- You can find available highlight options in the [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#_highlighted_fragments).
902
+ You can find available highlight options in the [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/highlighting.html).
903
903
 
904
904
  ## Similar Items
905
905
 
@@ -950,7 +950,7 @@ Boost results by distance - closer results are boosted more
950
950
  Restaurant.search "noodles", boost_by_distance: {location: {origin: {lat: 37, lon: -122}}}
951
951
  ```
952
952
 
953
- Also supports [additional options](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_decay_functions)
953
+ Also supports [additional options](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-decay)
954
954
 
955
955
  ```ruby
956
956
  Restaurant.search "wings", boost_by_distance: {location: {origin: {lat: 37, lon: -122}, function: "linear", scale: "30mi", decay: 0.5}}
@@ -1254,7 +1254,7 @@ Choose an add-on: [Bonsai](https://elements.heroku.com/addons/bonsai), [SearchBo
1254
1254
  For Bonsai:
1255
1255
 
1256
1256
  ```sh
1257
- heroku addons:create bonsai
1257
+ heroku addons:create bonsai # use --engine=opensearch for OpenSearch
1258
1258
  heroku config:set ELASTICSEARCH_URL=`heroku config:get BONSAI_URL`
1259
1259
  ```
1260
1260
 
@@ -1717,7 +1717,7 @@ Check out [this great post](https://www.tiagoamaro.com.br/2014/12/11/multi-tenan
1717
1717
 
1718
1718
  ## Scroll API
1719
1719
 
1720
- Searchkick also supports the [scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html). Scrolling is not intended for real time user requests, but rather for processing large amounts of data.
1720
+ Searchkick also supports the [scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#scroll-search-results). Scrolling is not intended for real time user requests, but rather for processing large amounts of data.
1721
1721
 
1722
1722
  ```ruby
1723
1723
  Product.search("*", scroll: "1m").scroll do |batch|
@@ -1970,7 +1970,7 @@ products = Product.search("carrots", execute: false)
1970
1970
  products.each { ... } # search not executed until here
1971
1971
  ```
1972
1972
 
1973
- Add [request parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html), like `search_type` and `query_cache`
1973
+ Add [request parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html#search-search-api-query-params) like `search_type`
1974
1974
 
1975
1975
  ```ruby
1976
1976
  Product.search("carrots", request_params: {search_type: "dfs_query_then_fetch"})
data/lib/searchkick.rb CHANGED
@@ -56,7 +56,7 @@ module Searchkick
56
56
  require "typhoeus/adapters/faraday" if defined?(Typhoeus) && Gem::Version.new(Faraday::VERSION) < Gem::Version.new("0.14.0")
57
57
 
58
58
  Elasticsearch::Client.new({
59
- url: ENV["ELASTICSEARCH_URL"],
59
+ url: ENV["ELASTICSEARCH_URL"] || ENV["OPENSEARCH_URL"],
60
60
  transport_options: {request: {timeout: timeout}, headers: {content_type: "application/json"}},
61
61
  retry_on_failure: 2
62
62
  }.deep_merge(client_options)) do |f|
@@ -110,7 +110,7 @@ module Searchkick
110
110
 
111
111
  # no easy way to tell which host the client will use
112
112
  host =
113
- if Elasticsearch::VERSION.to_f >= 7.14
113
+ if Gem::Version.new(Elasticsearch::VERSION) >= Gem::Version.new("7.14.0")
114
114
  Searchkick.client.transport.transport.hosts.first
115
115
  else
116
116
  Searchkick.client.transport.hosts.first
@@ -1028,10 +1028,6 @@ module Searchkick
1028
1028
  elsif value.nil?
1029
1029
  {bool: {must_not: {exists: {field: field}}}}
1030
1030
  elsif value.is_a?(Regexp)
1031
- if value.casefold?
1032
- Searchkick.warn("Case-insensitive flag does not work with Elasticsearch")
1033
- end
1034
-
1035
1031
  source = value.source
1036
1032
  unless source.start_with?("\\A") && source.end_with?("\\z")
1037
1033
  # https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
@@ -1053,7 +1049,14 @@ module Searchkick
1053
1049
  # source = "#{source}.*"
1054
1050
  end
1055
1051
 
1056
- {regexp: {field => {value: source, flags: "NONE"}}}
1052
+ if below710?
1053
+ if value.casefold?
1054
+ Searchkick.warn("Case-insensitive flag does not work with Elasticsearch < 7.10")
1055
+ end
1056
+ {regexp: {field => {value: source, flags: "NONE"}}}
1057
+ else
1058
+ {regexp: {field => {value: source, flags: "NONE", case_insensitive: value.casefold?}}}
1059
+ end
1057
1060
  else
1058
1061
  # TODO add this for other values
1059
1062
  if value.as_json.is_a?(Enumerable)
@@ -1151,5 +1154,9 @@ module Searchkick
1151
1154
  def below75?
1152
1155
  Searchkick.server_below?("7.5.0")
1153
1156
  end
1157
+
1158
+ def below710?
1159
+ Searchkick.server_below?("7.10.0")
1160
+ end
1154
1161
  end
1155
1162
  end
@@ -1,3 +1,3 @@
1
1
  module Searchkick
2
- VERSION = "4.5.2"
2
+ VERSION = "4.6.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.5.2
4
+ version: 4.6.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: 2021-08-05 00:00:00.000000000 Z
11
+ date: 2021-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -31,6 +31,9 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '6'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '7.14'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +41,9 @@ dependencies:
38
41
  - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '6'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '7.14'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: hashie
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +59,7 @@ dependencies:
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0'
55
61
  description:
56
- email: andrew@chartkick.com
62
+ email: andrew@ankane.org
57
63
  executables: []
58
64
  extensions: []
59
65
  extra_rdoc_files: []
@@ -105,5 +111,5 @@ requirements: []
105
111
  rubygems_version: 3.2.22
106
112
  signing_key:
107
113
  specification_version: 4
108
- summary: Intelligent search made easy with Rails and Elasticsearch
114
+ summary: Intelligent search made easy with Rails and Elasticsearch or OpenSearch
109
115
  test_files: []