searchkick 5.0.2 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -3
- data/lib/searchkick/model.rb +3 -3
- data/lib/searchkick/relation.rb +113 -0
- data/lib/searchkick/version.rb +1 -1
- data/lib/searchkick/where.rb +11 -0
- data/lib/searchkick.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec7741cb306a56f1a5ae5a07450c5c102236bc6103079fc34a5f602fa2853b31
|
4
|
+
data.tar.gz: 2bd747ee31846c901ce2a58125b34e9c90af6937a2c7dc041f2dd9f69701f1e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f92f2a3c7bb27862b1768f5ecedc19ad0eab515d62515f94d72412ed7c22a20493049dd0e52cba21b3a43d8c846b0dc0c6cda40c68edc12f6af37e8487fb9403
|
7
|
+
data.tar.gz: f69a1cfc401bad0f09bda3f2788b1096cc004dcb765eb20b3d8ada06202185eeae630d953005298e5944ed1b8c239fa808eeebb32e9440cc7ae9a32e771469dc
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -50,8 +50,8 @@ Searchkick 5.0 was recently released! See [how to upgrade](#upgrading)
|
|
50
50
|
Install [Elasticsearch](https://www.elastic.co/downloads/elasticsearch) or [OpenSearch](https://opensearch.org/downloads.html). For Homebrew, use:
|
51
51
|
|
52
52
|
```sh
|
53
|
-
brew install elasticsearch
|
54
|
-
brew services start elasticsearch
|
53
|
+
brew install elastic/tap/elasticsearch-full
|
54
|
+
brew services start elasticsearch-full
|
55
55
|
# or
|
56
56
|
brew install opensearch
|
57
57
|
brew services start opensearch
|
@@ -683,7 +683,7 @@ end
|
|
683
683
|
|
684
684
|
Reindex and set up a cron job to add new conversions daily.
|
685
685
|
|
686
|
-
```
|
686
|
+
```sh
|
687
687
|
rake searchkick:reindex CLASS=Product
|
688
688
|
```
|
689
689
|
|
data/lib/searchkick/model.rb
CHANGED
@@ -66,7 +66,7 @@ module Searchkick
|
|
66
66
|
alias_method Searchkick.search_method_name, :searchkick_search if Searchkick.search_method_name
|
67
67
|
|
68
68
|
def searchkick_index(name: nil)
|
69
|
-
index_name = name || searchkick_index_name
|
69
|
+
index_name = name || searchkick_klass.searchkick_index_name
|
70
70
|
index_name = index_name.call if index_name.respond_to?(:call)
|
71
71
|
index_cache = class_variable_get(:@@searchkick_index_cache)
|
72
72
|
index_cache.fetch(index_name) { Searchkick::Index.new(index_name, searchkick_options) }
|
@@ -88,9 +88,9 @@ module Searchkick
|
|
88
88
|
if options[:index_name]
|
89
89
|
options[:index_name]
|
90
90
|
elsif options[:index_prefix].respond_to?(:call)
|
91
|
-
-> { [options[:index_prefix].call,
|
91
|
+
-> { [options[:index_prefix].call, model_name.plural, Searchkick.env, Searchkick.index_suffix].compact.join("_") }
|
92
92
|
else
|
93
|
-
[options.key?(:index_prefix) ? options[:index_prefix] : Searchkick.index_prefix,
|
93
|
+
[options.key?(:index_prefix) ? options[:index_prefix] : Searchkick.index_prefix, model_name.plural, Searchkick.env, Searchkick.index_suffix].compact.join("_")
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
data/lib/searchkick/relation.rb
CHANGED
@@ -30,16 +30,19 @@ module Searchkick
|
|
30
30
|
self
|
31
31
|
end
|
32
32
|
|
33
|
+
# experimental
|
33
34
|
def limit(value)
|
34
35
|
clone.limit!(value)
|
35
36
|
end
|
36
37
|
|
38
|
+
# experimental
|
37
39
|
def limit!(value)
|
38
40
|
check_loaded
|
39
41
|
@options[:limit] = value
|
40
42
|
self
|
41
43
|
end
|
42
44
|
|
45
|
+
# experimental
|
43
46
|
def offset(value = NO_DEFAULT_VALUE)
|
44
47
|
# TODO remove in Searchkick 6
|
45
48
|
if value == NO_DEFAULT_VALUE
|
@@ -49,22 +52,26 @@ module Searchkick
|
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
55
|
+
# experimental
|
52
56
|
def offset!(value)
|
53
57
|
check_loaded
|
54
58
|
@options[:offset] = value
|
55
59
|
self
|
56
60
|
end
|
57
61
|
|
62
|
+
# experimental
|
58
63
|
def page(value)
|
59
64
|
clone.page!(value)
|
60
65
|
end
|
61
66
|
|
67
|
+
# experimental
|
62
68
|
def page!(value)
|
63
69
|
check_loaded
|
64
70
|
@options[:page] = value
|
65
71
|
self
|
66
72
|
end
|
67
73
|
|
74
|
+
# experimental
|
68
75
|
def per_page(value = NO_DEFAULT_VALUE)
|
69
76
|
# TODO remove in Searchkick 6
|
70
77
|
if value == NO_DEFAULT_VALUE
|
@@ -74,16 +81,116 @@ module Searchkick
|
|
74
81
|
end
|
75
82
|
end
|
76
83
|
|
84
|
+
# experimental
|
77
85
|
def per_page!(value)
|
78
86
|
check_loaded
|
79
87
|
@options[:per_page] = value
|
80
88
|
self
|
81
89
|
end
|
82
90
|
|
91
|
+
# experimental
|
92
|
+
def where(value = NO_DEFAULT_VALUE)
|
93
|
+
if value == NO_DEFAULT_VALUE
|
94
|
+
Where.new(self)
|
95
|
+
else
|
96
|
+
clone.where!(value)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# experimental
|
101
|
+
def where!(value)
|
102
|
+
check_loaded
|
103
|
+
if @options[:where]
|
104
|
+
@options[:where] = {_and: [@options[:where], ensure_permitted(value)]}
|
105
|
+
else
|
106
|
+
@options[:where] = ensure_permitted(value)
|
107
|
+
end
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
# experimental
|
112
|
+
def rewhere(value)
|
113
|
+
clone.rewhere!(value)
|
114
|
+
end
|
115
|
+
|
116
|
+
# experimental
|
117
|
+
def rewhere!(value)
|
118
|
+
check_loaded
|
119
|
+
@options[:where] = ensure_permitted(value)
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
# experimental
|
124
|
+
def order(*values)
|
125
|
+
clone.order!(*values)
|
126
|
+
end
|
127
|
+
|
128
|
+
# experimental
|
129
|
+
def order!(*values)
|
130
|
+
values = values.first if values.size == 1 && values.first.is_a?(Array)
|
131
|
+
check_loaded
|
132
|
+
(@options[:order] ||= []).concat(values)
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
# experimental
|
137
|
+
def reorder(*values)
|
138
|
+
clone.reorder!(*values)
|
139
|
+
end
|
140
|
+
|
141
|
+
# experimental
|
142
|
+
def reorder!(*values)
|
143
|
+
check_loaded
|
144
|
+
@options[:order] = values
|
145
|
+
self
|
146
|
+
end
|
147
|
+
|
148
|
+
# experimental
|
149
|
+
def select(*values, &block)
|
150
|
+
if block_given?
|
151
|
+
private_execute.select(*values, &block)
|
152
|
+
else
|
153
|
+
clone.select!(*values)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# experimental
|
158
|
+
def select!(*values)
|
159
|
+
check_loaded
|
160
|
+
(@options[:select] ||= []).concat(values)
|
161
|
+
self
|
162
|
+
end
|
163
|
+
|
164
|
+
# experimental
|
165
|
+
def reselect(*values)
|
166
|
+
clone.reselect!(*values)
|
167
|
+
end
|
168
|
+
|
169
|
+
# experimental
|
170
|
+
def reselect!(*values)
|
171
|
+
check_loaded
|
172
|
+
@options[:select] = values
|
173
|
+
self
|
174
|
+
end
|
175
|
+
|
176
|
+
# experimental
|
177
|
+
def includes(*values)
|
178
|
+
clone.includes!(*values)
|
179
|
+
end
|
180
|
+
|
181
|
+
# experimental
|
182
|
+
def includes!(*values)
|
183
|
+
check_loaded
|
184
|
+
(@options[:includes] ||= []).concat(values)
|
185
|
+
self
|
186
|
+
end
|
187
|
+
|
188
|
+
# experimental
|
83
189
|
def only(*keys)
|
84
190
|
Relation.new(@model, @term, **@options.slice(*keys))
|
85
191
|
end
|
86
192
|
|
193
|
+
# experimental
|
87
194
|
def except(*keys)
|
88
195
|
Relation.new(@model, @term, **@options.except(*keys))
|
89
196
|
end
|
@@ -108,5 +215,11 @@ module Searchkick
|
|
108
215
|
# reset query since options will change
|
109
216
|
@query = nil
|
110
217
|
end
|
218
|
+
|
219
|
+
# provides *very* basic protection from unfiltered parameters
|
220
|
+
# this is not meant to be comprehensive and may be expanded in the future
|
221
|
+
def ensure_permitted(obj)
|
222
|
+
obj.to_h
|
223
|
+
end
|
111
224
|
end
|
112
225
|
end
|
data/lib/searchkick/version.rb
CHANGED
data/lib/searchkick.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: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/searchkick/relation_indexer.rb
|
72
72
|
- lib/searchkick/results.rb
|
73
73
|
- lib/searchkick/version.rb
|
74
|
+
- lib/searchkick/where.rb
|
74
75
|
- lib/tasks/searchkick.rake
|
75
76
|
homepage: https://github.com/ankane/searchkick
|
76
77
|
licenses:
|
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
- !ruby/object:Gem::Version
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
|
-
rubygems_version: 3.3.
|
95
|
+
rubygems_version: 3.3.7
|
95
96
|
signing_key:
|
96
97
|
specification_version: 4
|
97
98
|
summary: Intelligent search made easy with Rails and Elasticsearch or OpenSearch
|