elasticsearch-rails-origin 7.2.3 → 7.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +7 -7
- data/README.md +149 -149
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20205a7b2d11a5a90a970fa76f4340adeec223d4e4d43363c47fc09ac081738e
|
4
|
+
data.tar.gz: 19cc8f286385469e9c2063babf6d49062e62f41f28c463b91567ea8f21565132
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a107900509860a4dfb774edf1eb1741012c34c689912fc9458bf20019e3b34231b553312a6e1661f0f2b9641f81c1231e6362b6a6c1890d576a18b6866d08afb
|
7
|
+
data.tar.gz: 395ca7aa8569b1cab975f7b952aac66f51542730273bc5648b675010a9a5eea344f4b806a2470f102a507ff25a4b65ae0587f1bd8b8036fb85aec3830d054f12
|
data/LICENSE.txt
CHANGED
@@ -1,8 +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
|
-
|
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
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
CHANGED
@@ -1,149 +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.
|
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
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-rails-origin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.2.
|
4
|
+
version: 7.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spencer Peloquin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -247,12 +247,12 @@ files:
|
|
247
247
|
- README.md
|
248
248
|
homepage: https://github.com/terrasky064/elasticrails-origin
|
249
249
|
licenses:
|
250
|
-
-
|
250
|
+
- Apache 2
|
251
251
|
metadata:
|
252
|
-
homepage_uri: https://
|
252
|
+
homepage_uri: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ruby_on_rails.html
|
253
253
|
changelog_uri: https://github.com/elastic/elasticsearch-rails/blob/main/CHANGELOG.md
|
254
|
-
source_code_uri: https://github.com/
|
255
|
-
bug_tracker_uri: https://github.com/
|
254
|
+
source_code_uri: https://github.com/elastic/elasticsearch-rails/
|
255
|
+
bug_tracker_uri: https://github.com/elastic/elasticsearch-rails/issues
|
256
256
|
post_install_message:
|
257
257
|
rdoc_options:
|
258
258
|
- "--charset=UTF-8"
|
@@ -262,7 +262,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
262
|
requirements:
|
263
263
|
- - ">="
|
264
264
|
- !ruby/object:Gem::Version
|
265
|
-
version: '2.
|
265
|
+
version: '2.4'
|
266
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
267
|
requirements:
|
268
268
|
- - ">="
|