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 +4 -4
- data/CHANGELOG.md +6 -0
- data/LICENSE.txt +1 -1
- data/README.md +10 -10
- data/lib/searchkick.rb +1 -1
- data/lib/searchkick/query.rb +13 -6
- data/lib/searchkick/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d93159910ecc579b56511b5d8c6908b34fecbce17b49ccbc264383068610feb9
|
|
4
|
+
data.tar.gz: a60319ffc12e2aac95bf96f616bb65afcb8e75b77a89598e960193c8424c677a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ce03474756a2adf3ada602580c6e56d2a39d39d93096b9d796167f9bc841a92b5d321914a05ab75ca9e10e87cf6e77ed8590b6e9934cae1ec0e56ba590f65c8
|
|
7
|
+
data.tar.gz: ae617b74a6ed27f6caa6bf9f3494a62d35ab4176e87bf868a5c04e60ae1b78462bee07de1f182cd3d81cac5a3bcaa22a57aad5e75f61c384aa8ceb6344822486
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
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)
|
|
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-
|
|
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-
|
|
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.
|
|
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/
|
|
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#
|
|
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-
|
|
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-
|
|
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|
|
data/lib/searchkick/query.rb
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
data/lib/searchkick/version.rb
CHANGED
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.
|
|
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-
|
|
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@
|
|
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: []
|