indices 0.0.1 → 4.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +13 -185
- data/MIT-LICENSE +0 -20
- data/README.md +0 -245
- data/Rakefile +0 -19
- data/lib/generators/indices/index_generator.rb +0 -15
- data/lib/generators/indices/install_generator.rb +0 -15
- data/lib/generators/indices/templates/index.rb +0 -12
- data/lib/generators/indices/templates/initializer.rb +0 -10
- data/lib/indices.rb +0 -102
- data/lib/indices/collection.rb +0 -195
- data/lib/indices/concern.rb +0 -23
- data/lib/indices/configuration.rb +0 -39
- data/lib/indices/dsl/api.rb +0 -85
- data/lib/indices/dsl/mappings.rb +0 -14
- data/lib/indices/dsl/search.rb +0 -25
- data/lib/indices/dsl/serializer.rb +0 -17
- data/lib/indices/index.rb +0 -149
- data/lib/indices/pagination.rb +0 -33
- data/lib/indices/proxy.rb +0 -17
- data/lib/indices/railtie.rb +0 -15
- data/lib/indices/version.rb +0 -5
- data/lib/tasks/indices.rake +0 -11
- data/test/dsl_test.rb +0 -92
- 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/indices/products_index.rb +0 -51
- data/test/dummy/app/indices/shops_index.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 -7
- data/test/dummy/config/database.yml.travis +0 -3
- 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/indices.rb +0 -67
- 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 -12
- data/test/dummy/db/migrate/20161104182219_create_shops.rb +0 -7
- data/test/dummy/db/schema.rb +0 -36
- data/test/dummy/log/development.log +0 -156
- data/test/dummy/log/test.log +0 -10249
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/generators_test.rb +0 -25
- data/test/indices_test.rb +0 -46
- data/test/record_test.rb +0 -25
- data/test/search_test.rb +0 -164
- data/test/tasks_test.rb +0 -25
- 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: bf3faa1b4ff1e6705a77f6c2de29f2de55ee55b5
|
4
|
+
data.tar.gz: d0893eb2d2f1021e6ab1191a7e05345682c8d243
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fbf4449a85b1a056d93429f6eb247f289069927f5e935328af9af935db3727fbdf510262db7589fa13ba1d83bb9b69c57fd517ef9ef8f76c8f998fa50d686e4
|
7
|
+
data.tar.gz: 8548b0d4cb862fc995b01aedb64ae7ede6e3ce9df158fa9a5437e10dab6ce0f4c14012b17ce69fe4c2705b5d80377737c819062398bbd94dd501070fce46efc2
|
metadata
CHANGED
@@ -1,161 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indices
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 4.0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mmontossi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: indexes
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 4.3.0
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 4.3.0
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: elasticsearch
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 2.0.0
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 2.0.0
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: pg
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.18'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.18'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: mocha
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1.1'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.1'
|
75
|
-
description: Model search indices with elasticsearch in rails.
|
26
|
+
version: '0'
|
27
|
+
description: 'THIS GEM HAS BEEN RENAMED TO: indexes'
|
76
28
|
email:
|
77
29
|
- mmontossi@gmail.com
|
78
30
|
executables: []
|
79
31
|
extensions: []
|
80
32
|
extra_rdoc_files: []
|
81
|
-
files:
|
82
|
-
|
83
|
-
- README.md
|
84
|
-
- Rakefile
|
85
|
-
- lib/generators/indices/index_generator.rb
|
86
|
-
- lib/generators/indices/install_generator.rb
|
87
|
-
- lib/generators/indices/templates/index.rb
|
88
|
-
- lib/generators/indices/templates/initializer.rb
|
89
|
-
- lib/indices.rb
|
90
|
-
- lib/indices/collection.rb
|
91
|
-
- lib/indices/concern.rb
|
92
|
-
- lib/indices/configuration.rb
|
93
|
-
- lib/indices/dsl/api.rb
|
94
|
-
- lib/indices/dsl/mappings.rb
|
95
|
-
- lib/indices/dsl/search.rb
|
96
|
-
- lib/indices/dsl/serializer.rb
|
97
|
-
- lib/indices/index.rb
|
98
|
-
- lib/indices/pagination.rb
|
99
|
-
- lib/indices/proxy.rb
|
100
|
-
- lib/indices/railtie.rb
|
101
|
-
- lib/indices/version.rb
|
102
|
-
- lib/tasks/indices.rake
|
103
|
-
- test/dsl_test.rb
|
104
|
-
- test/dummy/Rakefile
|
105
|
-
- test/dummy/app/assets/javascripts/application.js
|
106
|
-
- test/dummy/app/assets/stylesheets/application.css
|
107
|
-
- test/dummy/app/controllers/application_controller.rb
|
108
|
-
- test/dummy/app/helpers/application_helper.rb
|
109
|
-
- test/dummy/app/indices/products_index.rb
|
110
|
-
- test/dummy/app/indices/shops_index.rb
|
111
|
-
- test/dummy/app/models/product.rb
|
112
|
-
- test/dummy/app/models/shop.rb
|
113
|
-
- test/dummy/app/views/layouts/application.html.erb
|
114
|
-
- test/dummy/bin/bundle
|
115
|
-
- test/dummy/bin/rails
|
116
|
-
- test/dummy/bin/rake
|
117
|
-
- test/dummy/bin/setup
|
118
|
-
- test/dummy/config.ru
|
119
|
-
- test/dummy/config/application.rb
|
120
|
-
- test/dummy/config/boot.rb
|
121
|
-
- test/dummy/config/database.yml
|
122
|
-
- test/dummy/config/database.yml.travis
|
123
|
-
- test/dummy/config/environment.rb
|
124
|
-
- test/dummy/config/environments/development.rb
|
125
|
-
- test/dummy/config/environments/production.rb
|
126
|
-
- test/dummy/config/environments/test.rb
|
127
|
-
- test/dummy/config/initializers/assets.rb
|
128
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
129
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
130
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
131
|
-
- test/dummy/config/initializers/indices.rb
|
132
|
-
- test/dummy/config/initializers/inflections.rb
|
133
|
-
- test/dummy/config/initializers/mime_types.rb
|
134
|
-
- test/dummy/config/initializers/session_store.rb
|
135
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
136
|
-
- test/dummy/config/locales/en.yml
|
137
|
-
- test/dummy/config/routes.rb
|
138
|
-
- test/dummy/config/secrets.yml
|
139
|
-
- test/dummy/db/migrate/20161104164148_create_products.rb
|
140
|
-
- test/dummy/db/migrate/20161104182219_create_shops.rb
|
141
|
-
- test/dummy/db/schema.rb
|
142
|
-
- test/dummy/log/development.log
|
143
|
-
- test/dummy/log/test.log
|
144
|
-
- test/dummy/public/404.html
|
145
|
-
- test/dummy/public/422.html
|
146
|
-
- test/dummy/public/500.html
|
147
|
-
- test/dummy/public/favicon.ico
|
148
|
-
- test/generators_test.rb
|
149
|
-
- test/indices_test.rb
|
150
|
-
- test/record_test.rb
|
151
|
-
- test/search_test.rb
|
152
|
-
- test/tasks_test.rb
|
153
|
-
- test/test_helper.rb
|
154
|
-
homepage: https://github.com/mmontossi/indices
|
33
|
+
files: []
|
34
|
+
homepage: https://github.com/mmontossi/indexes
|
155
35
|
licenses:
|
156
36
|
- MIT
|
157
37
|
metadata: {}
|
158
|
-
post_install_message:
|
38
|
+
post_install_message: 'THIS GEM HAS BEEN RENAMED TO: indexes'
|
159
39
|
rdoc_options: []
|
160
40
|
require_paths:
|
161
41
|
- lib
|
@@ -163,68 +43,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
43
|
requirements:
|
164
44
|
- - ">="
|
165
45
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
46
|
+
version: '0'
|
167
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
48
|
requirements:
|
169
49
|
- - ">="
|
170
50
|
- !ruby/object:Gem::Version
|
171
51
|
version: '0'
|
172
|
-
requirements:
|
173
|
-
- Elasticsearch
|
52
|
+
requirements: []
|
174
53
|
rubyforge_project:
|
175
54
|
rubygems_version: 2.5.1
|
176
55
|
signing_key:
|
177
56
|
specification_version: 4
|
178
|
-
summary:
|
179
|
-
test_files:
|
180
|
-
- test/dsl_test.rb
|
181
|
-
- test/dummy/app/assets/javascripts/application.js
|
182
|
-
- test/dummy/app/assets/stylesheets/application.css
|
183
|
-
- test/dummy/app/controllers/application_controller.rb
|
184
|
-
- test/dummy/app/helpers/application_helper.rb
|
185
|
-
- test/dummy/app/indices/products_index.rb
|
186
|
-
- test/dummy/app/indices/shops_index.rb
|
187
|
-
- test/dummy/app/models/product.rb
|
188
|
-
- test/dummy/app/models/shop.rb
|
189
|
-
- test/dummy/app/views/layouts/application.html.erb
|
190
|
-
- test/dummy/bin/bundle
|
191
|
-
- test/dummy/bin/rails
|
192
|
-
- test/dummy/bin/rake
|
193
|
-
- test/dummy/bin/setup
|
194
|
-
- test/dummy/config/application.rb
|
195
|
-
- test/dummy/config/boot.rb
|
196
|
-
- test/dummy/config/database.yml
|
197
|
-
- test/dummy/config/database.yml.travis
|
198
|
-
- test/dummy/config/environment.rb
|
199
|
-
- test/dummy/config/environments/development.rb
|
200
|
-
- test/dummy/config/environments/production.rb
|
201
|
-
- test/dummy/config/environments/test.rb
|
202
|
-
- test/dummy/config/initializers/assets.rb
|
203
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
204
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
205
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
206
|
-
- test/dummy/config/initializers/indices.rb
|
207
|
-
- test/dummy/config/initializers/inflections.rb
|
208
|
-
- test/dummy/config/initializers/mime_types.rb
|
209
|
-
- test/dummy/config/initializers/session_store.rb
|
210
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
211
|
-
- test/dummy/config/locales/en.yml
|
212
|
-
- test/dummy/config/routes.rb
|
213
|
-
- test/dummy/config/secrets.yml
|
214
|
-
- test/dummy/config.ru
|
215
|
-
- test/dummy/db/migrate/20161104164148_create_products.rb
|
216
|
-
- test/dummy/db/migrate/20161104182219_create_shops.rb
|
217
|
-
- test/dummy/db/schema.rb
|
218
|
-
- test/dummy/log/development.log
|
219
|
-
- test/dummy/log/test.log
|
220
|
-
- test/dummy/public/404.html
|
221
|
-
- test/dummy/public/422.html
|
222
|
-
- test/dummy/public/500.html
|
223
|
-
- test/dummy/public/favicon.ico
|
224
|
-
- test/dummy/Rakefile
|
225
|
-
- test/generators_test.rb
|
226
|
-
- test/indices_test.rb
|
227
|
-
- test/record_test.rb
|
228
|
-
- test/search_test.rb
|
229
|
-
- test/tasks_test.rb
|
230
|
-
- test/test_helper.rb
|
57
|
+
summary: 'THIS GEM HAS BEEN RENAMED TO: indexes'
|
58
|
+
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2016 Mathías Montossi
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,245 +0,0 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/indices.svg)](http://badge.fury.io/rb/indices)
|
2
|
-
[![Code Climate](https://codeclimate.com/github/mmontossi/indices/badges/gpa.svg)](https://codeclimate.com/github/mmontossi/indices)
|
3
|
-
[![Build Status](https://travis-ci.org/mmontossi/indices.svg)](https://travis-ci.org/mmontossi/indices)
|
4
|
-
[![Dependency Status](https://gemnasium.com/mmontossi/indices.svg)](https://gemnasium.com/mmontossi/indices)
|
5
|
-
|
6
|
-
# Indices
|
7
|
-
|
8
|
-
Model search indices with elasticsearch in rails.
|
9
|
-
|
10
|
-
## Why
|
11
|
-
|
12
|
-
I did this gem to:
|
13
|
-
|
14
|
-
- Gain control of the queries without losing simplicity.
|
15
|
-
- Have out of the box integration with activerecord and pagers.
|
16
|
-
- Deal with the just in time nature of elasticsearch.
|
17
|
-
- Integrate activerecord tool on it.
|
18
|
-
- Have a convention of how to integrate suggestions.
|
19
|
-
|
20
|
-
## Install
|
21
|
-
|
22
|
-
Put this line in your Gemfile:
|
23
|
-
```ruby
|
24
|
-
gem 'indices'
|
25
|
-
```
|
26
|
-
|
27
|
-
Then bundle:
|
28
|
-
```
|
29
|
-
$ bundle
|
30
|
-
```
|
31
|
-
|
32
|
-
To install Redis you can use homebrew:
|
33
|
-
```
|
34
|
-
brew install elasticsearch24
|
35
|
-
```
|
36
|
-
|
37
|
-
NOTE: This gem is tested agains version 2.4.
|
38
|
-
|
39
|
-
## Configuration
|
40
|
-
|
41
|
-
Generate the configuration file:
|
42
|
-
```
|
43
|
-
bundle exec rails g indices:install
|
44
|
-
```
|
45
|
-
|
46
|
-
Configure the global settings:
|
47
|
-
```ruby
|
48
|
-
Indices.configure do |config|
|
49
|
-
|
50
|
-
config.hosts = %w(localhost:9200)
|
51
|
-
config.log = false
|
52
|
-
config.trace = false
|
53
|
-
|
54
|
-
config.mappings do
|
55
|
-
name do
|
56
|
-
type 'string'
|
57
|
-
fields do
|
58
|
-
raw do
|
59
|
-
type 'string'
|
60
|
-
index 'not_analyzed'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
category type: 'string'
|
65
|
-
price type: 'long'
|
66
|
-
currency type: 'string'
|
67
|
-
product_suggestions do
|
68
|
-
type 'completion'
|
69
|
-
analyzer 'simple'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
config.analysis do
|
74
|
-
filter do
|
75
|
-
ngram do
|
76
|
-
type 'nGram'
|
77
|
-
min_gram 2
|
78
|
-
max_gram 20
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
config.suggestions do |name, term, options={}|
|
84
|
-
type = name.to_s.singularize
|
85
|
-
text (term || '')
|
86
|
-
completion do
|
87
|
-
field "#{type}_suggestions"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
config.add_computed_sort :price do |direction|
|
92
|
-
_script do
|
93
|
-
type 'number'
|
94
|
-
script do
|
95
|
-
inline "if (_source.currency == 'UYU') { doc['price'].value * 30 }"
|
96
|
-
end
|
97
|
-
order direction
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
```
|
103
|
-
|
104
|
-
Generate an index:
|
105
|
-
```
|
106
|
-
bundle exec rails g indices:index products
|
107
|
-
```
|
108
|
-
|
109
|
-
Configure the index:
|
110
|
-
```ruby
|
111
|
-
Indices.define :products do
|
112
|
-
|
113
|
-
mappings do
|
114
|
-
properties :name, :category, :price, :product_suggestions
|
115
|
-
end
|
116
|
-
|
117
|
-
serializer do |record|
|
118
|
-
set record, :name, :category, :price
|
119
|
-
product_suggestions do
|
120
|
-
input [record.name, transliterate(record.name)].uniq
|
121
|
-
output record.name
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
search do |*args|
|
126
|
-
options = args.extract_options!
|
127
|
-
term = args.first
|
128
|
-
query do
|
129
|
-
if term.present?
|
130
|
-
multi_match do
|
131
|
-
query term
|
132
|
-
type 'phrase_prefix'
|
133
|
-
fields %w(name category)
|
134
|
-
end
|
135
|
-
else
|
136
|
-
match_all
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
```
|
143
|
-
|
144
|
-
## Usage
|
145
|
-
|
146
|
-
### Indexing
|
147
|
-
|
148
|
-
Ocurrs everytime you create or destroy a record:
|
149
|
-
```ruby
|
150
|
-
product = Product.create(name: 'Les Paul', category: 'Gibson')
|
151
|
-
```
|
152
|
-
|
153
|
-
You can force it manually by:
|
154
|
-
```ruby
|
155
|
-
product.index
|
156
|
-
product.reindex
|
157
|
-
product.unindex
|
158
|
-
```
|
159
|
-
|
160
|
-
At any time you can force a full rebuild:
|
161
|
-
```
|
162
|
-
bundle exec rake indices:rebuild
|
163
|
-
```
|
164
|
-
|
165
|
-
Or if you need it, just a build:
|
166
|
-
```
|
167
|
-
bundle exec rake indices:build
|
168
|
-
```
|
169
|
-
|
170
|
-
### Search
|
171
|
-
|
172
|
-
The search parameters are sent to previous configured block:
|
173
|
-
```ruby
|
174
|
-
@products = Product.search(name: 'Test')
|
175
|
-
```
|
176
|
-
|
177
|
-
You can use the returned value as a collection in views:
|
178
|
-
```erb
|
179
|
-
<%= render @products %>
|
180
|
-
```
|
181
|
-
|
182
|
-
### Includes
|
183
|
-
|
184
|
-
Same as using activerecord relations:
|
185
|
-
```ruby
|
186
|
-
Product.search(includes: :shop)
|
187
|
-
```
|
188
|
-
|
189
|
-
### With / Without
|
190
|
-
|
191
|
-
You can force a record to be part of the results by id:
|
192
|
-
```ruby
|
193
|
-
Product.search(with: 4)
|
194
|
-
```
|
195
|
-
|
196
|
-
Or the opposite:
|
197
|
-
```ruby
|
198
|
-
Product.search(without: 4)
|
199
|
-
```
|
200
|
-
|
201
|
-
### Pagination
|
202
|
-
|
203
|
-
Works the same as [Pagers gem](https://github.com/mmontossi/pagers):
|
204
|
-
```ruby
|
205
|
-
@products.page 1, padding: 4, length: 30
|
206
|
-
```
|
207
|
-
|
208
|
-
And you can send the collection directly to the helper in views:
|
209
|
-
```erb
|
210
|
-
<%= paginate @products %>
|
211
|
-
```
|
212
|
-
|
213
|
-
### Order
|
214
|
-
|
215
|
-
Works the same as in relations:
|
216
|
-
```ruby
|
217
|
-
@products.order(name: :asc)
|
218
|
-
```
|
219
|
-
|
220
|
-
To use a computed_sort:
|
221
|
-
```ruby
|
222
|
-
@products.order(price: :asc)
|
223
|
-
```
|
224
|
-
|
225
|
-
NOTE: To sort by a string column, you must declare the mapping raw.
|
226
|
-
|
227
|
-
### Suggestions
|
228
|
-
|
229
|
-
The suggestion parameters are sent to previous configured block:
|
230
|
-
```ruby
|
231
|
-
Indices.suggest :products, 'gibson'
|
232
|
-
```
|
233
|
-
|
234
|
-
Returns array of hashes with a text property:
|
235
|
-
```ruby
|
236
|
-
[{ text: 'Les Paul' }, ...]
|
237
|
-
```
|
238
|
-
|
239
|
-
## Credits
|
240
|
-
|
241
|
-
This gem is maintained and funded by [mmontossi](https://github.com/mmontossi).
|
242
|
-
|
243
|
-
## License
|
244
|
-
|
245
|
-
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|