indexers 4.1.0.1 → 5.1.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/MIT-LICENSE +1 -1
- data/README.md +17 -23
- data/Rakefile +1 -3
- data/lib/indexers.rb +1 -1
- data/lib/indexers/collection.rb +10 -12
- data/lib/indexers/concern.rb +1 -1
- data/lib/indexers/version.rb +1 -1
- metadata +18 -129
- data/test/dsl_test.rb +0 -127
- data/test/dummy/Rakefile +0 -5
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/indexers/product_indexer.rb +0 -55
- data/test/dummy/app/indexers/shop_indexer.rb +0 -28
- data/test/dummy/app/models/product.rb +0 -5
- data/test/dummy/app/models/shop.rb +0 -5
- data/test/dummy/app/views/layouts/application.html.erb +0 -12
- data/test/dummy/bin/bundle +0 -4
- data/test/dummy/bin/rails +0 -5
- data/test/dummy/bin/rake +0 -5
- data/test/dummy/bin/setup +0 -30
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -25
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -10
- data/test/dummy/config/database.yml.travis +0 -3
- data/test/dummy/config/elasticsearch.yml +0 -15
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -41
- data/test/dummy/config/environments/production.rb +0 -79
- data/test/dummy/config/environments/test.rb +0 -42
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/indexers.rb +0 -65
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/db/migrate/20161104164148_create_products.rb +0 -14
- data/test/dummy/db/migrate/20161104182219_create_shops.rb +0 -9
- data/test/dummy/db/schema.rb +0 -36
- data/test/dummy/log/development.log +0 -114
- data/test/dummy/log/test.log +0 -21168
- data/test/dummy/public/404.html +0 -61
- data/test/dummy/public/422.html +0 -61
- data/test/dummy/public/500.html +0 -60
- data/test/dummy/public/favicon.ico +0 -0
- data/test/generator_test.rb +0 -26
- data/test/index_test.rb +0 -42
- data/test/record_test.rb +0 -25
- data/test/search_test.rb +0 -164
- data/test/task_test.rb +0 -31
- data/test/test_helper.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cd1b4b219caffd4cd86cf1f86a49aaa90fe8911
|
4
|
+
data.tar.gz: 6fd8d22673623460b65ecd70c6d1655f4baa02fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bbf0c594fd26479d00c5a9fa69782b22d64427b145126e9f1ed7d7178dae78e089ab2a751407728dd67ef8d619fcf10bace527bcfc4e8d74b596e698e767317
|
7
|
+
data.tar.gz: a06663d9bb75f8bb9e3fe74e39bf6b3de31bc9d65ec7723fa12fa2e7fb37e1162291bdbc696ebcb1a2e19b632dd7c7e6aed4570758107d6fffeb7f1fe8268622
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[](http://badge.fury.io/rb/indexers)
|
2
|
-
[](https://codeclimate.com/github/museways/indexers)
|
3
|
+
[](https://travis-ci.org/museways/indexers)
|
4
|
+
[](https://gemnasium.com/museways/indexers)
|
5
5
|
|
6
6
|
# Indexers
|
7
7
|
|
@@ -31,10 +31,10 @@ $ bundle
|
|
31
31
|
|
32
32
|
To install Redis you can use homebrew:
|
33
33
|
```
|
34
|
-
$ brew install
|
34
|
+
$ brew install elasticsearch
|
35
35
|
```
|
36
36
|
|
37
|
-
NOTE: This gem is tested agains version
|
37
|
+
NOTE: This gem is tested agains version 5.4.
|
38
38
|
|
39
39
|
## Configuration
|
40
40
|
|
@@ -52,8 +52,7 @@ Indexers.configure do |config|
|
|
52
52
|
type 'string'
|
53
53
|
fields do
|
54
54
|
raw do
|
55
|
-
type '
|
56
|
-
index 'not_analyzed'
|
55
|
+
type 'keyword'
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
@@ -69,7 +68,7 @@ Indexers.configure do |config|
|
|
69
68
|
end
|
70
69
|
```
|
71
70
|
|
72
|
-
If you need to personalize the analysis
|
71
|
+
If you need to personalize the analysis:
|
73
72
|
|
74
73
|
```ruby
|
75
74
|
Indexers.configure do |config|
|
@@ -115,7 +114,6 @@ Indexers.define :product do
|
|
115
114
|
extract record, :name, :category, :price
|
116
115
|
product_suggestions do
|
117
116
|
input [record.name, transliterate(record.name)].uniq
|
118
|
-
output record.name
|
119
117
|
end
|
120
118
|
end
|
121
119
|
|
@@ -149,9 +147,8 @@ Indexers.define :product do
|
|
149
147
|
shop = options[:shop]
|
150
148
|
term = args.first
|
151
149
|
query do
|
152
|
-
|
153
|
-
|
154
|
-
query do
|
150
|
+
bool do
|
151
|
+
must do
|
155
152
|
if term.present?
|
156
153
|
multi_match do
|
157
154
|
query term
|
@@ -162,19 +159,16 @@ Indexers.define :product do
|
|
162
159
|
match_all
|
163
160
|
end
|
164
161
|
end
|
162
|
+
traits :shop
|
165
163
|
end
|
166
164
|
end
|
167
165
|
end
|
168
166
|
|
169
167
|
trait :shop do
|
170
168
|
filter do
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
term do
|
175
|
-
_parent shop.id
|
176
|
-
end
|
177
|
-
end
|
169
|
+
if shop
|
170
|
+
term do
|
171
|
+
_parent shop.id
|
178
172
|
end
|
179
173
|
end
|
180
174
|
end
|
@@ -229,7 +223,7 @@ Product.search.includes(:shop)
|
|
229
223
|
|
230
224
|
### Pagination
|
231
225
|
|
232
|
-
Works the same as [pagers gem](https://github.com/
|
226
|
+
Works the same as [pagers gem](https://github.com/museways/pagers):
|
233
227
|
```ruby
|
234
228
|
Products.search.page(1, padding: 4, length: 30)
|
235
229
|
```
|
@@ -263,7 +257,7 @@ Indexers.configure do |config|
|
|
263
257
|
config.computed_sort :price do |direction|
|
264
258
|
type 'number'
|
265
259
|
script do
|
266
|
-
inline "if (_source
|
260
|
+
inline "if (params['_source']['currency'] == 'UYU') { doc['price'].value * 30 }"
|
267
261
|
end
|
268
262
|
order direction
|
269
263
|
end
|
@@ -302,11 +296,11 @@ The result is an array of hashes with a text property:
|
|
302
296
|
|
303
297
|
Any issue, pull request, comment of any kind is more than welcome!
|
304
298
|
|
305
|
-
I will mainly ensure compatibility to
|
299
|
+
I will mainly ensure compatibility to Rails, AWS, PostgreSQL, Redis, Elasticsearch and FreeBSD.
|
306
300
|
|
307
301
|
## Credits
|
308
302
|
|
309
|
-
This gem is maintained and funded by [
|
303
|
+
This gem is maintained and funded by [museways](https://github.com/museways).
|
310
304
|
|
311
305
|
## License
|
312
306
|
|
data/Rakefile
CHANGED
@@ -4,16 +4,14 @@ rescue LoadError
|
|
4
4
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
5
|
end
|
6
6
|
|
7
|
-
|
7
|
+
require 'bundler/gem_tasks'
|
8
8
|
|
9
9
|
require 'rake/testtask'
|
10
10
|
|
11
11
|
Rake::TestTask.new(:test) do |t|
|
12
|
-
t.libs << 'lib'
|
13
12
|
t.libs << 'test'
|
14
13
|
t.pattern = 'test/**/*_test.rb'
|
15
14
|
t.verbose = false
|
16
|
-
t.warning = false
|
17
15
|
end
|
18
16
|
|
19
17
|
task default: :test
|
data/lib/indexers.rb
CHANGED
data/lib/indexers/collection.rb
CHANGED
@@ -56,7 +56,7 @@ module Indexers
|
|
56
56
|
values << { _script: Dsl::Api.new(direction, &block).to_h }
|
57
57
|
elsif property == :id
|
58
58
|
values << { _uid: { order: direction } }
|
59
|
-
elsif mappings.has_key?(property) && mappings[property][:type] == '
|
59
|
+
elsif mappings.has_key?(property) && mappings[property][:type] == 'text'
|
60
60
|
values << { "#{property}.raw" => { order: direction } }
|
61
61
|
end
|
62
62
|
end
|
@@ -84,19 +84,17 @@ module Indexers
|
|
84
84
|
request = Dsl::Search.new do
|
85
85
|
if without_ids.any?
|
86
86
|
query do
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
87
|
+
bool do
|
88
|
+
must do
|
89
|
+
body
|
90
|
+
end
|
91
|
+
must_not do
|
92
|
+
without_ids.each do |id|
|
93
|
+
term do
|
94
|
+
_id id
|
96
95
|
end
|
97
96
|
end
|
98
97
|
end
|
99
|
-
query body
|
100
98
|
end
|
101
99
|
end
|
102
100
|
else
|
@@ -155,7 +153,7 @@ module Indexers
|
|
155
153
|
|
156
154
|
def fetch_ids(source)
|
157
155
|
case source
|
158
|
-
when
|
156
|
+
when Integer,String
|
159
157
|
[source.to_i]
|
160
158
|
when ActiveRecord::Base
|
161
159
|
[source.id]
|
data/lib/indexers/concern.rb
CHANGED
data/lib/indexers/version.rb
CHANGED
metadata
CHANGED
@@ -1,80 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indexers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mmontossi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 4.2.0
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: '5.1'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 4.2.0
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
26
|
+
version: '5.1'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: elasticsearch
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
33
|
+
version: '5.0'
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
version: '5.0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: pg
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
47
|
+
version: '0.21'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
54
|
+
version: '0.21'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: mocha
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: '1.
|
61
|
+
version: '1.2'
|
68
62
|
type: :development
|
69
63
|
prerelease: false
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
66
|
- - "~>"
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version: '1.
|
68
|
+
version: '1.2'
|
75
69
|
description: Dsl to delegate searches to elasticsearch in rails.
|
76
70
|
email:
|
77
|
-
-
|
71
|
+
- hi@museways.com
|
78
72
|
executables: []
|
79
73
|
extensions: []
|
80
74
|
extra_rdoc_files: []
|
@@ -105,59 +99,7 @@ files:
|
|
105
99
|
- lib/indexers/railtie.rb
|
106
100
|
- lib/indexers/version.rb
|
107
101
|
- lib/tasks/indexers.rake
|
108
|
-
|
109
|
-
- test/dummy/Rakefile
|
110
|
-
- test/dummy/app/assets/javascripts/application.js
|
111
|
-
- test/dummy/app/assets/stylesheets/application.css
|
112
|
-
- test/dummy/app/controllers/application_controller.rb
|
113
|
-
- test/dummy/app/helpers/application_helper.rb
|
114
|
-
- test/dummy/app/indexers/product_indexer.rb
|
115
|
-
- test/dummy/app/indexers/shop_indexer.rb
|
116
|
-
- test/dummy/app/models/product.rb
|
117
|
-
- test/dummy/app/models/shop.rb
|
118
|
-
- test/dummy/app/views/layouts/application.html.erb
|
119
|
-
- test/dummy/bin/bundle
|
120
|
-
- test/dummy/bin/rails
|
121
|
-
- test/dummy/bin/rake
|
122
|
-
- test/dummy/bin/setup
|
123
|
-
- test/dummy/config.ru
|
124
|
-
- test/dummy/config/application.rb
|
125
|
-
- test/dummy/config/boot.rb
|
126
|
-
- test/dummy/config/database.yml
|
127
|
-
- test/dummy/config/database.yml.travis
|
128
|
-
- test/dummy/config/elasticsearch.yml
|
129
|
-
- test/dummy/config/environment.rb
|
130
|
-
- test/dummy/config/environments/development.rb
|
131
|
-
- test/dummy/config/environments/production.rb
|
132
|
-
- test/dummy/config/environments/test.rb
|
133
|
-
- test/dummy/config/initializers/assets.rb
|
134
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
135
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
136
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
137
|
-
- test/dummy/config/initializers/indexers.rb
|
138
|
-
- test/dummy/config/initializers/inflections.rb
|
139
|
-
- test/dummy/config/initializers/mime_types.rb
|
140
|
-
- test/dummy/config/initializers/session_store.rb
|
141
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
142
|
-
- test/dummy/config/locales/en.yml
|
143
|
-
- test/dummy/config/routes.rb
|
144
|
-
- test/dummy/config/secrets.yml
|
145
|
-
- test/dummy/db/migrate/20161104164148_create_products.rb
|
146
|
-
- test/dummy/db/migrate/20161104182219_create_shops.rb
|
147
|
-
- test/dummy/db/schema.rb
|
148
|
-
- test/dummy/log/development.log
|
149
|
-
- test/dummy/log/test.log
|
150
|
-
- test/dummy/public/404.html
|
151
|
-
- test/dummy/public/422.html
|
152
|
-
- test/dummy/public/500.html
|
153
|
-
- test/dummy/public/favicon.ico
|
154
|
-
- test/generator_test.rb
|
155
|
-
- test/index_test.rb
|
156
|
-
- test/record_test.rb
|
157
|
-
- test/search_test.rb
|
158
|
-
- test/task_test.rb
|
159
|
-
- test/test_helper.rb
|
160
|
-
homepage: https://github.com/mmontossi/indexers
|
102
|
+
homepage: https://github.com/museways/indexers
|
161
103
|
licenses:
|
162
104
|
- MIT
|
163
105
|
metadata: {}
|
@@ -169,69 +111,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
169
111
|
requirements:
|
170
112
|
- - ">="
|
171
113
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
114
|
+
version: '0'
|
173
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
116
|
requirements:
|
175
117
|
- - ">="
|
176
118
|
- !ruby/object:Gem::Version
|
177
119
|
version: '0'
|
178
|
-
requirements:
|
179
|
-
- Elasticsearch
|
120
|
+
requirements: []
|
180
121
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.6.13
|
182
123
|
signing_key:
|
183
124
|
specification_version: 4
|
184
125
|
summary: Search indexers for rails.
|
185
|
-
test_files:
|
186
|
-
- test/dsl_test.rb
|
187
|
-
- test/dummy/app/assets/javascripts/application.js
|
188
|
-
- test/dummy/app/assets/stylesheets/application.css
|
189
|
-
- test/dummy/app/controllers/application_controller.rb
|
190
|
-
- test/dummy/app/helpers/application_helper.rb
|
191
|
-
- test/dummy/app/indexers/product_indexer.rb
|
192
|
-
- test/dummy/app/indexers/shop_indexer.rb
|
193
|
-
- test/dummy/app/models/product.rb
|
194
|
-
- test/dummy/app/models/shop.rb
|
195
|
-
- test/dummy/app/views/layouts/application.html.erb
|
196
|
-
- test/dummy/bin/bundle
|
197
|
-
- test/dummy/bin/rails
|
198
|
-
- test/dummy/bin/rake
|
199
|
-
- test/dummy/bin/setup
|
200
|
-
- test/dummy/config/application.rb
|
201
|
-
- test/dummy/config/boot.rb
|
202
|
-
- test/dummy/config/database.yml
|
203
|
-
- test/dummy/config/database.yml.travis
|
204
|
-
- test/dummy/config/elasticsearch.yml
|
205
|
-
- test/dummy/config/environment.rb
|
206
|
-
- test/dummy/config/environments/development.rb
|
207
|
-
- test/dummy/config/environments/production.rb
|
208
|
-
- test/dummy/config/environments/test.rb
|
209
|
-
- test/dummy/config/initializers/assets.rb
|
210
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
211
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
212
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
213
|
-
- test/dummy/config/initializers/indexers.rb
|
214
|
-
- test/dummy/config/initializers/inflections.rb
|
215
|
-
- test/dummy/config/initializers/mime_types.rb
|
216
|
-
- test/dummy/config/initializers/session_store.rb
|
217
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
218
|
-
- test/dummy/config/locales/en.yml
|
219
|
-
- test/dummy/config/routes.rb
|
220
|
-
- test/dummy/config/secrets.yml
|
221
|
-
- test/dummy/config.ru
|
222
|
-
- test/dummy/db/migrate/20161104164148_create_products.rb
|
223
|
-
- test/dummy/db/migrate/20161104182219_create_shops.rb
|
224
|
-
- test/dummy/db/schema.rb
|
225
|
-
- test/dummy/log/development.log
|
226
|
-
- test/dummy/log/test.log
|
227
|
-
- test/dummy/public/404.html
|
228
|
-
- test/dummy/public/422.html
|
229
|
-
- test/dummy/public/500.html
|
230
|
-
- test/dummy/public/favicon.ico
|
231
|
-
- test/dummy/Rakefile
|
232
|
-
- test/generator_test.rb
|
233
|
-
- test/index_test.rb
|
234
|
-
- test/record_test.rb
|
235
|
-
- test/search_test.rb
|
236
|
-
- test/task_test.rb
|
237
|
-
- test/test_helper.rb
|
126
|
+
test_files: []
|