elasticsearch-rails-origin 7.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +8 -0
- data/README.md +149 -0
- metadata +276 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2d7443c168418e3af3399120d330b8ca3aee01ce937a7e81bb202286147a2649
|
4
|
+
data.tar.gz: 4271e9dcfc9cf73f6b0aaa9580572587ebc8754f9ab7eb1ce90f95d6cce0a308
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d3c3248a60f0871213d776ee0f652d906bb64a35232753ea7a3905b2bd00e2610c8a0ac19e62d095a6bb1f02bb459f1c566a57de80a3248e3a5341331dd4449
|
7
|
+
data.tar.gz: c828cca9895819b71f9ee7c76f15719051455cbb16eb280744e56e8513e8777091383a3e005e4f5782fe651ec99e1fb5acc95618038ab2c96b2ffc778eedd3c9
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright © 2022 Spencer Peloquin
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# Elasticsearch::Rails
|
2
|
+
|
3
|
+
The `elasticsearch-rails` library is a companion for the
|
4
|
+
the [`elasticsearch-model`](https://github.com/terrasky064/elasticrails)
|
5
|
+
library, providing features suitable for Ruby on Rails applications.
|
6
|
+
|
7
|
+
## Compatibility
|
8
|
+
|
9
|
+
This library is compatible with Ruby 1.9.3 and higher.
|
10
|
+
|
11
|
+
The library version numbers follow the Elasticsearch major versions, and the `main` branch
|
12
|
+
is compatible with the Elasticsearch `master` branch, therefore, with the next major version.
|
13
|
+
|
14
|
+
| Rubygem | | Elasticsearch |
|
15
|
+
|:-------------:|:-:| :-----------: |
|
16
|
+
| 0.1 | → | 1.x |
|
17
|
+
| 2.x | → | 2.x |
|
18
|
+
| 5.x | → | 5.x |
|
19
|
+
| 6.x | → | 6.x |
|
20
|
+
| 7.x | → | 7.x |
|
21
|
+
| main | → | master |
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Install the package from [Rubygems](https://rubygems.org):
|
26
|
+
|
27
|
+
gem install elasticsearch-rails
|
28
|
+
|
29
|
+
To use an unreleased version, either add it to your `Gemfile` for [Bundler](http://bundler.io):
|
30
|
+
|
31
|
+
gem 'elasticsearch-rails', git: 'git://github.com/elastic/elasticsearch-rails.git', branch: '5.x'
|
32
|
+
|
33
|
+
or install it from a source code checkout:
|
34
|
+
|
35
|
+
git clone https://github.com/terrasky064/elasticrails
|
36
|
+
cd elasticsearch-rails/elasticsearch-rails
|
37
|
+
bundle install
|
38
|
+
rake install
|
39
|
+
|
40
|
+
## Features
|
41
|
+
|
42
|
+
### Rake Tasks
|
43
|
+
|
44
|
+
To facilitate importing data from your models into Elasticsearch, require the task definition in your application,
|
45
|
+
eg. in the `lib/tasks/elasticsearch.rake` file:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'elasticsearch/rails/tasks/import'
|
49
|
+
```
|
50
|
+
|
51
|
+
To import the records from your `Article` model, run:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
$ bundle exec rake environment elasticsearch:import:model CLASS='Article'
|
55
|
+
```
|
56
|
+
|
57
|
+
To limit the imported records to a certain
|
58
|
+
ActiveRecord [scope](http://guides.rubyonrails.org/active_record_querying.html#scopes),
|
59
|
+
pass it to the task:
|
60
|
+
|
61
|
+
```bash
|
62
|
+
$ bundle exec rake environment elasticsearch:import:model CLASS='Article' SCOPE='published'
|
63
|
+
```
|
64
|
+
|
65
|
+
Run this command to display usage instructions:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
$ bundle exec rake -D elasticsearch
|
69
|
+
```
|
70
|
+
|
71
|
+
### ActiveSupport Instrumentation
|
72
|
+
|
73
|
+
To display information about the search request (duration, search definition) during development,
|
74
|
+
and to include the information in the Rails log file, require the component in your `application.rb` file:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
require 'elasticsearch/rails/instrumentation'
|
78
|
+
```
|
79
|
+
|
80
|
+
You should see an output like this in your application log in development environment:
|
81
|
+
|
82
|
+
Article Search (321.3ms) { index: "articles", type: "article", body: { query: ... } }
|
83
|
+
|
84
|
+
Also, the total duration of the request to Elasticsearch is displayed in the Rails request breakdown:
|
85
|
+
|
86
|
+
Completed 200 OK in 615ms (Views: 230.9ms | ActiveRecord: 0.0ms | Elasticsearch: 321.3ms)
|
87
|
+
|
88
|
+
There's a special component for the [Lograge](https://github.com/roidrage/lograge) logger.
|
89
|
+
Require the component in your `application.rb` file (and set `config.lograge.enabled`):
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
require 'elasticsearch/rails/lograge'
|
93
|
+
```
|
94
|
+
|
95
|
+
You should see the duration of the request to Elasticsearch as part of each log event:
|
96
|
+
|
97
|
+
method=GET path=/search ... status=200 duration=380.89 view=99.64 db=0.00 es=279.37
|
98
|
+
|
99
|
+
### Rails Application Templates
|
100
|
+
|
101
|
+
You can generate a fully working example Ruby on Rails application, with an `Article` model and a search form,
|
102
|
+
to play with (it generates the application skeleton and leaves you with a _Git_ repository to explore the
|
103
|
+
steps and the code) with the
|
104
|
+
[`01-basic.rb`](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-rails/lib/rails/templates/01-basic.rb) template:
|
105
|
+
|
106
|
+
```bash
|
107
|
+
rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/01-basic.rb
|
108
|
+
```
|
109
|
+
|
110
|
+
Run the same command again, in the same folder, with the
|
111
|
+
[`02-pretty`](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-rails/lib/rails/templates/02-pretty.rb)
|
112
|
+
template to add features such as a custom `Article.search` method, result highlighting and
|
113
|
+
[_Bootstrap_](http://getbootstrap.com) integration:
|
114
|
+
|
115
|
+
```bash
|
116
|
+
rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/02-pretty.rb
|
117
|
+
```
|
118
|
+
|
119
|
+
Run the same command with the [`03-expert.rb`](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-rails/lib/rails/templates/03-expert.rb)
|
120
|
+
template to refactor the application into a more complex use case,
|
121
|
+
with couple of hundreds of The New York Times articles as the example content.
|
122
|
+
The template will extract the Elasticsearch integration into a `Searchable` "concern" module,
|
123
|
+
define complex mapping, custom serialization, implement faceted navigation and suggestions as a part of
|
124
|
+
a complex query, and add a _Sidekiq_-based worker for updating the index in the background.
|
125
|
+
|
126
|
+
```bash
|
127
|
+
rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/03-expert.rb
|
128
|
+
```
|
129
|
+
|
130
|
+
## License
|
131
|
+
|
132
|
+
This software is licensed under the Apache 2 license, quoted below.
|
133
|
+
|
134
|
+
Licensed to Elasticsearch B.V. under one or more contributor
|
135
|
+
license agreements. See the NOTICE file distributed with
|
136
|
+
this work for additional information regarding copyright
|
137
|
+
ownership. Elasticsearch B.V. licenses this file to you under
|
138
|
+
the Apache License, Version 2.0 (the "License"); you may
|
139
|
+
not use this file except in compliance with the License.
|
140
|
+
You may obtain a copy of the License at
|
141
|
+
|
142
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
143
|
+
|
144
|
+
Unless required by applicable law or agreed to in writing,
|
145
|
+
software distributed under the License is distributed on an
|
146
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
147
|
+
KIND, either express or implied. See the License for the
|
148
|
+
specific language governing permissions and limitations
|
149
|
+
under the License.
|
metadata
ADDED
@@ -0,0 +1,276 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elasticsearch-rails-origin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 7.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Spencer Peloquin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cane
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: lograge
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.1'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '12'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '12'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: require-prof
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: shoulda-context
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: test-unit
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: turn
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: yard
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: oj
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: ruby-prof
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
description: Ruby on Rails integrations for Elasticsearch.
|
238
|
+
email:
|
239
|
+
- spencercon253@hotmail.com
|
240
|
+
executables: []
|
241
|
+
extensions: []
|
242
|
+
extra_rdoc_files:
|
243
|
+
- README.md
|
244
|
+
- LICENSE.txt
|
245
|
+
files:
|
246
|
+
- LICENSE.txt
|
247
|
+
- README.md
|
248
|
+
homepage: https://github.com/terrasky064/elasticrails-origin
|
249
|
+
licenses:
|
250
|
+
- MIT
|
251
|
+
metadata:
|
252
|
+
homepage_uri: https://github.com/terrasky064/elasticrails-origin
|
253
|
+
changelog_uri: https://github.com/elastic/elasticsearch-rails/blob/main/CHANGELOG.md
|
254
|
+
source_code_uri: https://github.com/terrasky064/elasticrails-origin
|
255
|
+
bug_tracker_uri: https://github.com/terrasky064/elasticrails-origin
|
256
|
+
post_install_message:
|
257
|
+
rdoc_options:
|
258
|
+
- "--charset=UTF-8"
|
259
|
+
require_paths:
|
260
|
+
- lib
|
261
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
262
|
+
requirements:
|
263
|
+
- - ">="
|
264
|
+
- !ruby/object:Gem::Version
|
265
|
+
version: '2.7'
|
266
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
|
+
requirements:
|
268
|
+
- - ">="
|
269
|
+
- !ruby/object:Gem::Version
|
270
|
+
version: '0'
|
271
|
+
requirements: []
|
272
|
+
rubygems_version: 3.3.7
|
273
|
+
signing_key:
|
274
|
+
specification_version: 4
|
275
|
+
summary: Ruby on Rails integrations for Elasticsearch.
|
276
|
+
test_files: []
|