es-elasticity 0.13.5 → 1.0.0.jhumphreys
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +43 -42
- data/CHANGELOG.md +18 -0
- data/CONTRIBUTING.md +11 -12
- data/Gemfile.lock +53 -34
- data/README.md +48 -44
- data/es-elasticity.gemspec +7 -7
- data/lib/elasticity/base_document.rb +3 -1
- data/lib/elasticity/bulk.rb +20 -18
- data/lib/elasticity/config.rb +2 -0
- data/lib/elasticity/document.rb +2 -0
- data/lib/elasticity/index_config.rb +19 -5
- data/lib/elasticity/index_mapper.rb +10 -9
- data/lib/elasticity/instrumented_client.rb +2 -0
- data/lib/elasticity/log_subscriber.rb +2 -0
- data/lib/elasticity/multi_search.rb +2 -0
- data/lib/elasticity/multi_search_response_parser.rb +3 -0
- data/lib/elasticity/railtie.rb +3 -1
- data/lib/elasticity/search.rb +7 -5
- data/lib/elasticity/segmented_document.rb +2 -0
- data/lib/elasticity/strategies/alias_index.rb +32 -39
- data/lib/elasticity/strategies/single_index.rb +16 -20
- data/lib/elasticity/strategies.rb +2 -0
- data/lib/elasticity/version.rb +3 -1
- metadata +27 -22
- data/lib/elasticity/scrollable_search.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ae09251206ad3a404852a933845ba8f1229f2115f9f131b7e60755563e00fd
|
4
|
+
data.tar.gz: 5860875d6f70b7469b5799de6e5390e4106f503d7fc04cc6e025b2565acc94c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d299cb65873ddf6d0a65a837a9b4466b8bc76567f7df7f114e55ed02e6aab934018a97295cdfb4b81402eed5dcbcf0f4c3090b3bf6b322641eedc552a41206be
|
7
|
+
data.tar.gz: e82316e49624da957279567ca6f3e1f3c6083446729d739b2dd470a595783f2bcdfc11d7ebf76ceec7a82852f7c42f5372252a2c9971fcebd29ccfdf97202385
|
data/.circleci/config.yml
CHANGED
@@ -4,47 +4,47 @@ orbs:
|
|
4
4
|
gem: doximity/gem-publisher@0
|
5
5
|
|
6
6
|
executors:
|
7
|
-
|
8
7
|
# used for building the gem
|
9
8
|
ruby-latest:
|
10
9
|
resource_class: small
|
11
10
|
docker:
|
12
|
-
- image:
|
11
|
+
- image: cimg/ruby:3.1
|
13
12
|
environment:
|
14
|
-
BUNDLE_VERSION:
|
13
|
+
BUNDLE_VERSION: '~> 2.3.4'
|
15
14
|
|
16
15
|
# used for testing the gem:
|
17
|
-
|
16
|
+
ruby_2_7:
|
18
17
|
resource_class: small
|
19
18
|
docker:
|
20
|
-
- image:
|
19
|
+
- image: cimg/ruby:2.7
|
21
20
|
environment:
|
22
|
-
BUNDLE_VERSION:
|
23
|
-
- image: elastic/elasticsearch:
|
21
|
+
BUNDLE_VERSION: '~> 2.3.4'
|
22
|
+
- image: docker.elastic.co/elasticsearch/elasticsearch:7.17.3
|
24
23
|
environment:
|
25
|
-
-
|
24
|
+
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
|
26
25
|
- discovery.type=single-node
|
27
26
|
- xpack.security.enabled=false
|
28
|
-
|
27
|
+
ruby_3_0:
|
29
28
|
resource_class: small
|
30
29
|
docker:
|
31
|
-
- image:
|
30
|
+
- image: cimg/ruby:3.0
|
32
31
|
environment:
|
33
|
-
BUNDLE_VERSION:
|
34
|
-
- image: elastic/elasticsearch:
|
32
|
+
BUNDLE_VERSION: '~> 2.3.4'
|
33
|
+
- image: docker.elastic.co/elasticsearch/elasticsearch:7.17.3
|
35
34
|
environment:
|
36
|
-
-
|
35
|
+
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
|
37
36
|
- discovery.type=single-node
|
38
37
|
- xpack.security.enabled=false
|
39
|
-
|
38
|
+
|
39
|
+
ruby_3_1:
|
40
40
|
resource_class: small
|
41
41
|
docker:
|
42
|
-
- image:
|
42
|
+
- image: cimg/ruby:3.1
|
43
43
|
environment:
|
44
|
-
BUNDLE_VERSION:
|
45
|
-
- image: elastic/elasticsearch:
|
44
|
+
BUNDLE_VERSION: '~> 2.3.4'
|
45
|
+
- image: docker.elastic.co/elasticsearch/elasticsearch:7.17.3
|
46
46
|
environment:
|
47
|
-
-
|
47
|
+
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
|
48
48
|
- discovery.type=single-node
|
49
49
|
- xpack.security.enabled=false
|
50
50
|
|
@@ -69,8 +69,8 @@ version_tags_only: &version_tags_only
|
|
69
69
|
only: /^v.*/
|
70
70
|
|
71
71
|
jobs:
|
72
|
-
|
73
|
-
executor:
|
72
|
+
build_2_7:
|
73
|
+
executor: ruby_2_7
|
74
74
|
steps:
|
75
75
|
- checkout
|
76
76
|
- run:
|
@@ -79,12 +79,12 @@ jobs:
|
|
79
79
|
gem install bundler --version "${BUNDLE_VERSION}" --force
|
80
80
|
- restore_cache:
|
81
81
|
keys:
|
82
|
-
-
|
82
|
+
- v3-bundle-ruby_2_7-{{ checksum "Gemfile.lock" }}
|
83
83
|
- run:
|
84
84
|
name: Install Ruby Dependencies
|
85
85
|
command: bundle check --path=vendor/bundle || bundle install --local --frozen --path=vendor/bundle --jobs=4 --retry=3
|
86
86
|
- save_cache:
|
87
|
-
key:
|
87
|
+
key: v3-bundle-ruby_2_7-{{ checksum "Gemfile.lock" }}
|
88
88
|
paths:
|
89
89
|
- vendor/bundle
|
90
90
|
- run:
|
@@ -97,8 +97,8 @@ jobs:
|
|
97
97
|
root: .
|
98
98
|
paths:
|
99
99
|
- vendor/bundle
|
100
|
-
|
101
|
-
executor:
|
100
|
+
build_3_0:
|
101
|
+
executor: ruby_3_0
|
102
102
|
steps:
|
103
103
|
- checkout
|
104
104
|
- run:
|
@@ -107,12 +107,12 @@ jobs:
|
|
107
107
|
gem install bundler --version "${BUNDLE_VERSION}" --force
|
108
108
|
- restore_cache:
|
109
109
|
keys:
|
110
|
-
-
|
110
|
+
- v3-bundle-ruby_3_0-{{ checksum "Gemfile.lock" }}
|
111
111
|
- run:
|
112
112
|
name: Install Ruby Dependencies
|
113
113
|
command: bundle check --path=vendor/bundle || bundle install --local --frozen --path=vendor/bundle --jobs=4 --retry=3
|
114
114
|
- save_cache:
|
115
|
-
key:
|
115
|
+
key: v3-bundle-ruby_3_0-{{ checksum "Gemfile.lock" }}
|
116
116
|
paths:
|
117
117
|
- vendor/bundle
|
118
118
|
- run:
|
@@ -125,8 +125,9 @@ jobs:
|
|
125
125
|
root: .
|
126
126
|
paths:
|
127
127
|
- vendor/bundle
|
128
|
-
|
129
|
-
|
128
|
+
|
129
|
+
build_3_1:
|
130
|
+
executor: ruby_3_1
|
130
131
|
steps:
|
131
132
|
- checkout
|
132
133
|
- run:
|
@@ -135,12 +136,12 @@ jobs:
|
|
135
136
|
gem install bundler --version "${BUNDLE_VERSION}" --force
|
136
137
|
- restore_cache:
|
137
138
|
keys:
|
138
|
-
-
|
139
|
+
- v3-bundle-ruby_3_1-{{ checksum "Gemfile.lock" }}
|
139
140
|
- run:
|
140
141
|
name: Install Ruby Dependencies
|
141
142
|
command: bundle check --path=vendor/bundle || bundle install --local --frozen --path=vendor/bundle --jobs=4 --retry=3
|
142
143
|
- save_cache:
|
143
|
-
key:
|
144
|
+
key: v3-bundle-ruby_3_1-{{ checksum "Gemfile.lock" }}
|
144
145
|
paths:
|
145
146
|
- vendor/bundle
|
146
147
|
- run:
|
@@ -158,33 +159,33 @@ workflows:
|
|
158
159
|
version: 2
|
159
160
|
trunk:
|
160
161
|
jobs:
|
161
|
-
-
|
162
|
+
- build_2_7:
|
162
163
|
<<: *master_only
|
163
|
-
-
|
164
|
+
- build_3_0:
|
164
165
|
<<: *master_only
|
165
|
-
-
|
166
|
+
- build_3_1:
|
166
167
|
<<: *master_only
|
167
168
|
- gem/build:
|
168
169
|
<<: *master_only
|
169
170
|
executor: ruby-latest
|
170
171
|
name: gem-build
|
171
172
|
requires:
|
172
|
-
-
|
173
|
+
- build_3_1
|
173
174
|
|
174
175
|
pull-requests:
|
175
176
|
jobs:
|
176
|
-
-
|
177
|
+
- build_2_7:
|
177
178
|
<<: *pr_only
|
178
|
-
-
|
179
|
+
- build_3_0:
|
179
180
|
<<: *pr_only
|
180
|
-
-
|
181
|
+
- build_3_1:
|
181
182
|
<<: *pr_only
|
182
183
|
- gem/build:
|
183
184
|
<<: *pr_only
|
184
185
|
executor: ruby-latest
|
185
186
|
name: gem-build
|
186
187
|
requires:
|
187
|
-
-
|
188
|
+
- build_3_1
|
188
189
|
- pre-release-approval:
|
189
190
|
<<: *pr_only
|
190
191
|
type: approval
|
@@ -201,18 +202,18 @@ workflows:
|
|
201
202
|
|
202
203
|
final-release:
|
203
204
|
jobs:
|
204
|
-
-
|
205
|
+
- build_2_7:
|
205
206
|
<<: *version_tags_only
|
206
|
-
-
|
207
|
+
- build_3_0:
|
207
208
|
<<: *version_tags_only
|
208
|
-
-
|
209
|
+
- build_3_1:
|
209
210
|
<<: *version_tags_only
|
210
211
|
- gem/build:
|
211
212
|
<<: *version_tags_only
|
212
213
|
executor: ruby-latest
|
213
214
|
name: gem-build
|
214
215
|
requires:
|
215
|
-
-
|
216
|
+
- build_3_1
|
216
217
|
- gem/publish:
|
217
218
|
<<: *version_tags_only
|
218
219
|
name: gem-publish
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.0.jhumphreys] - 2022-08-08
|
10
|
+
### Changed
|
11
|
+
- Consitently use quotations
|
12
|
+
- Update API to remove deprecation warnings for Elasticsearch 7.X.X in preparation for upgrade to 8.
|
13
|
+
- Update copyright notice date
|
14
|
+
- Freeze string literals
|
15
|
+
- Remove `_type` from query/create/update/delete methods
|
16
|
+
- Remove `use_new_timestamp_format` config
|
17
|
+
- Remove `include_type_name_on_create` config
|
18
|
+
|
19
|
+
## [0.14.0] - 2022-08-04
|
20
|
+
### Changed
|
21
|
+
- Use `refresh` instead of `flush` where search is expected to be updated
|
22
|
+
- Drop support for Ruby 2.5 and 2.6
|
23
|
+
- Add support for Ruby 2.7 and 3.0, build against Ruby 3.1
|
24
|
+
- Set `search_type` to `query_then_fetch` as we no longer support Elasticsearch version < 7.0
|
25
|
+
- Set `include_type_name` when fetching the mapping. Will be removed in the next version to support ES version 8.
|
26
|
+
- Index names automatically use the new timestamp format when creating an index.
|
9
27
|
|
10
28
|
## [0.13.5] - 2020-05-21
|
11
29
|
### Changed
|
data/CONTRIBUTING.md
CHANGED
@@ -1,31 +1,30 @@
|
|
1
|
-
# Contributing
|
1
|
+
# Contributing to Doximity
|
2
2
|
|
3
3
|
We welcome contributions to this repository. Feel free to submit issues for bugs you encounter and pull requests for code and documentation contributions.
|
4
|
+
In order to prevent licensing issues, Doximity Inc. (“Doximity”, “we”, “us”) requires all contributors to agree to an Individual Contributor License Agreement (“CLA”), which is reproduced below. By submitting your contributions to us, you agree that you have read and are bound by the CLA. If you do not agree with the CLA, you may not submit contributions.
|
4
5
|
|
5
|
-
|
6
|
+
## Doximity Individual Contributor License Agreement
|
6
7
|
|
7
|
-
|
8
|
+
This license is for your protection as a Contributor as well as the protection of Doximity; it does not change your rights to use your own Contributions for any other purpose.
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Doximity. Except for the license granted herein to Doximity and recipients of software distributed by Doximity, You reserve all right, title, and interest in and to Your Contributions.
|
10
|
+
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Doximity. Except for the license granted herein to Doximity and recipients of software distributed by Doximity, You reserve all right, titles, and interests in and to Your Contributions.
|
12
11
|
|
13
12
|
### Definitions
|
14
13
|
|
15
|
-
"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Doximity. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
14
|
+
"You" (or "Your" or the “Contributor”) shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Doximity. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
16
15
|
|
17
|
-
1. "Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Doximity for inclusion in, or documentation of, any of the products owned or managed by Doximity (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to Doximity or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Doximity for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
|
16
|
+
1. "Contribution" shall mean the code, documentation, or any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Doximity for inclusion in, or documentation of, any of the products owned or managed by Doximity (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to Doximity or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Doximity for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution."
|
18
17
|
|
19
18
|
2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to Doximity and to recipients of software distributed by Doximity a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.
|
20
19
|
|
21
|
-
3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to Doximity and to recipients of software distributed by Doximity a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
|
20
|
+
3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to Doximity and to recipients of software distributed by Doximity a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by a combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes a direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
|
22
21
|
|
23
|
-
4. You represent that
|
22
|
+
4. You represent that You are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to Doximity, or that your employer has executed a separate Corporate CLA with Doximity.
|
24
23
|
|
25
24
|
5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions.
|
26
25
|
|
27
|
-
6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-
|
26
|
+
6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
28
27
|
|
29
|
-
7. Should You wish to submit work that is not Your original creation, You may submit it to Doximity separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [
|
28
|
+
7. Should You wish to submit work that is not Your original creation, You may submit it to Doximity separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]".
|
30
29
|
|
31
30
|
8. You agree to notify Doximity of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect.
|
data/Gemfile.lock
CHANGED
@@ -1,48 +1,68 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
es-elasticity (0.
|
5
|
-
activemodel (>=
|
6
|
-
activerecord (>=
|
7
|
-
activesupport (>=
|
8
|
-
elasticsearch (>=
|
4
|
+
es-elasticity (1.0.0.jhumphreys)
|
5
|
+
activemodel (>= 5.2.0, < 7.1)
|
6
|
+
activerecord (>= 5.2.0, < 7.1)
|
7
|
+
activesupport (>= 5.2.0, < 7.1)
|
8
|
+
elasticsearch (>= 7, < 8)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://artifacts.dox.support/repository/gems/
|
12
12
|
specs:
|
13
|
-
activemodel (
|
14
|
-
activesupport (=
|
15
|
-
activerecord (
|
16
|
-
activemodel (=
|
17
|
-
activesupport (=
|
18
|
-
activesupport (
|
13
|
+
activemodel (7.0.3.1)
|
14
|
+
activesupport (= 7.0.3.1)
|
15
|
+
activerecord (7.0.3.1)
|
16
|
+
activemodel (= 7.0.3.1)
|
17
|
+
activesupport (= 7.0.3.1)
|
18
|
+
activesupport (7.0.3.1)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
-
i18n (>=
|
21
|
-
minitest (
|
22
|
-
tzinfo (~>
|
23
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
20
|
+
i18n (>= 1.6, < 2)
|
21
|
+
minitest (>= 5.1)
|
22
|
+
tzinfo (~> 2.0)
|
24
23
|
byebug (11.0.1)
|
25
24
|
codeclimate-test-reporter (1.0.9)
|
26
25
|
simplecov (<= 0.13)
|
27
26
|
coderay (1.1.2)
|
28
|
-
concurrent-ruby (1.1.
|
27
|
+
concurrent-ruby (1.1.10)
|
29
28
|
diff-lcs (1.3)
|
30
|
-
elasticsearch (7.
|
31
|
-
elasticsearch-api (= 7.
|
32
|
-
elasticsearch-transport (= 7.
|
33
|
-
elasticsearch-api (7.
|
29
|
+
elasticsearch (7.17.1)
|
30
|
+
elasticsearch-api (= 7.17.1)
|
31
|
+
elasticsearch-transport (= 7.17.1)
|
32
|
+
elasticsearch-api (7.17.1)
|
34
33
|
multi_json
|
35
|
-
elasticsearch-transport (7.
|
34
|
+
elasticsearch-transport (7.17.1)
|
36
35
|
faraday (~> 1)
|
37
36
|
multi_json
|
38
|
-
faraday (1.0
|
39
|
-
|
40
|
-
|
37
|
+
faraday (1.10.0)
|
38
|
+
faraday-em_http (~> 1.0)
|
39
|
+
faraday-em_synchrony (~> 1.0)
|
40
|
+
faraday-excon (~> 1.1)
|
41
|
+
faraday-httpclient (~> 1.0)
|
42
|
+
faraday-multipart (~> 1.0)
|
43
|
+
faraday-net_http (~> 1.0)
|
44
|
+
faraday-net_http_persistent (~> 1.0)
|
45
|
+
faraday-patron (~> 1.0)
|
46
|
+
faraday-rack (~> 1.0)
|
47
|
+
faraday-retry (~> 1.0)
|
48
|
+
ruby2_keywords (>= 0.0.4)
|
49
|
+
faraday-em_http (1.0.0)
|
50
|
+
faraday-em_synchrony (1.0.0)
|
51
|
+
faraday-excon (1.1.0)
|
52
|
+
faraday-httpclient (1.0.1)
|
53
|
+
faraday-multipart (1.0.4)
|
54
|
+
multipart-post (~> 2)
|
55
|
+
faraday-net_http (1.0.1)
|
56
|
+
faraday-net_http_persistent (1.2.0)
|
57
|
+
faraday-patron (1.0.0)
|
58
|
+
faraday-rack (1.0.0)
|
59
|
+
faraday-retry (1.0.3)
|
60
|
+
i18n (1.12.0)
|
41
61
|
concurrent-ruby (~> 1.0)
|
42
62
|
method_source (0.9.2)
|
43
|
-
minitest (5.
|
44
|
-
multi_json (1.
|
45
|
-
multipart-post (2.
|
63
|
+
minitest (5.16.2)
|
64
|
+
multi_json (1.15.0)
|
65
|
+
multipart-post (2.2.3)
|
46
66
|
oj (3.10.0)
|
47
67
|
pry (0.12.2)
|
48
68
|
coderay (~> 1.1.0)
|
@@ -63,21 +83,20 @@ GEM
|
|
63
83
|
rspec-support (3.1.2)
|
64
84
|
rspec_junit_formatter (0.4.1)
|
65
85
|
rspec-core (>= 2, < 4, != 2.12.0)
|
86
|
+
ruby2_keywords (0.0.5)
|
66
87
|
simplecov (0.7.1)
|
67
88
|
multi_json (~> 1.0)
|
68
89
|
simplecov-html (~> 0.7.1)
|
69
90
|
simplecov-html (0.7.1)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
thread_safe (~> 0.1)
|
74
|
-
zeitwerk (2.3.0)
|
91
|
+
timecop (0.9.5)
|
92
|
+
tzinfo (2.0.5)
|
93
|
+
concurrent-ruby (~> 1.0)
|
75
94
|
|
76
95
|
PLATFORMS
|
77
96
|
ruby
|
78
97
|
|
79
98
|
DEPENDENCIES
|
80
|
-
bundler (~>
|
99
|
+
bundler (~> 2.3.4)
|
81
100
|
byebug
|
82
101
|
codeclimate-test-reporter
|
83
102
|
es-elasticity!
|
@@ -91,4 +110,4 @@ DEPENDENCIES
|
|
91
110
|
timecop
|
92
111
|
|
93
112
|
BUNDLED WITH
|
94
|
-
|
113
|
+
2.3.4
|
data/README.md
CHANGED
@@ -29,9 +29,10 @@ Or install it yourself as:
|
|
29
29
|
## Usage
|
30
30
|
|
31
31
|
### Version Support
|
32
|
-
This gem has [elasticsearch-ruby](https://github.com/elastic/elasticsearch-ruby) as a dependency. In order to use different versions of elasticsearch you will need to match your version of elasticsearch-ruby to the version of elasticsearch you want to use ([see here](https://github.com/elastic/elasticsearch-ruby#compatibility). Elasticity should work across all versions of elastisearch-ruby, although they have not all been tested so there are likely edge cases.
|
33
32
|
|
34
|
-
|
33
|
+
This gem has [elasticsearch-ruby](https://github.com/elastic/elasticsearch-ruby) as a dependency. In order to use different versions of elasticsearch you will need to match your version of elasticsearch-ruby to the version of elasticsearch you want to use ([see here](https://github.com/elastic/elasticsearch-ruby#compatibility). Elasticity should work across all versions of elastisearch-ruby, although they have not all been tested so there are likely edge cases.
|
34
|
+
|
35
|
+
Currently tests are run on CirlceCI against elasticsearch 7.17.3 with elasticsearch-ruby 7.17.1.
|
35
36
|
|
36
37
|
### Configuration
|
37
38
|
|
@@ -149,7 +150,6 @@ documents = [
|
|
149
150
|
Search::User.bulk_update(documents)
|
150
151
|
```
|
151
152
|
|
152
|
-
|
153
153
|
### Searching
|
154
154
|
|
155
155
|
Class methods have access to the `search` method, which returns a lazy evaluated search. That means that the search will only be performed when the data is necessary, not when the `search` method is called.
|
@@ -194,7 +194,8 @@ adults = adults.active_records(User)
|
|
194
194
|
#### Search Args
|
195
195
|
|
196
196
|
##### explain: true
|
197
|
-
|
197
|
+
|
198
|
+
For `search` definitions we support passing `{ explain: true }` to the search as a second argument in order to surface the reason a search result was returned.
|
198
199
|
|
199
200
|
```ruby
|
200
201
|
# example in single search
|
@@ -211,6 +212,7 @@ multi = Elasticity::MultiSearch.new do |m|
|
|
211
212
|
m.add(:c, search_c, documents: ::SearchDoc::C)
|
212
213
|
end
|
213
214
|
```
|
215
|
+
|
214
216
|
For more information about the `active_records` method, read [ActiveRecord integration](#activerecord-integration).
|
215
217
|
|
216
218
|
### Segmented Documents
|
@@ -324,15 +326,15 @@ When the mapping needs to change, a hot remapping can be performed by doing the
|
|
324
326
|
1. Create a new index with the new mapping;
|
325
327
|
2. change the update alias to point to the new index, and change main alias to point to both indexes; at this point it will look something like this:
|
326
328
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
329
|
+
```
|
330
|
+
|¯¯¯¯¯¯¯¯¯¯¯¯¯|----------------------> |¯¯¯¯¯¯¯¯¯¯¯¯¯|
|
331
|
+
| MainAlias | | Old Index |
|
332
|
+
|_____________|----------| |_____________|
|
333
|
+
|
|
334
|
+
|¯¯¯¯¯¯¯¯¯¯¯¯¯| |-----------> |¯¯¯¯¯¯¯¯¯¯¯¯¯|
|
335
|
+
| UpdateAlias |----------------------> | New Index |
|
336
|
+
|_____________| |_____________|
|
337
|
+
```
|
336
338
|
|
337
339
|
3. iterate over all documents on the old index, copying them to the new index;
|
338
340
|
4. change aliases to point only to the new index;
|
@@ -344,43 +346,43 @@ This is a simplified version, there are other things that happen to ensure consi
|
|
344
346
|
|
345
347
|
ActiveRecord integration is mainly a set of conventions rather than implementation, with the exception of one method that allows mapping documents back to a relation. Here is the list of conventions:
|
346
348
|
|
347
|
-
|
348
|
-
|
349
|
-
|
349
|
+
- have a class method on the document called `from_active_record` that creates a document object from the active record object;
|
350
|
+
- have a class method on the Document for rebuilding the index from the records;
|
351
|
+
- have an `after_save` and an `after_destroy` callbacks on the ActiveRecord model;
|
350
352
|
|
351
353
|
For example:
|
352
354
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
355
|
+
```ruby
|
356
|
+
class User < ActiveRecord::Base
|
357
|
+
after_save :update_index_document
|
358
|
+
after_destroy :delete_index_document
|
357
359
|
|
358
|
-
|
359
|
-
|
360
|
-
|
360
|
+
def update_index_document
|
361
|
+
Search::User.from_active_record(self).update
|
362
|
+
end
|
361
363
|
|
362
|
-
|
363
|
-
|
364
|
-
end
|
364
|
+
def delete_index_document
|
365
|
+
Search::User.delete(self.id)
|
365
366
|
end
|
367
|
+
end
|
366
368
|
|
367
|
-
|
368
|
-
|
369
|
+
class Search::User < Elasticity::Document
|
370
|
+
# ... configuration
|
369
371
|
|
370
|
-
|
371
|
-
|
372
|
-
|
372
|
+
def self.from_active_record(ar)
|
373
|
+
new(name: ar.name, birthdate: ar.birthdate)
|
374
|
+
end
|
373
375
|
|
374
|
-
|
375
|
-
|
376
|
+
def self.rebuild_index
|
377
|
+
self.recreate_index
|
376
378
|
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
end
|
379
|
+
User.find_in_batches do |batch|
|
380
|
+
documents = batch.map { |record| from_active_record(record) }
|
381
|
+
self.bulk_index(documents)
|
381
382
|
end
|
382
383
|
end
|
383
|
-
|
384
|
+
end
|
385
|
+
```
|
384
386
|
|
385
387
|
This makes the code very clear in intent, easier to see when and how things happen and under the developer control, keeping both parts very decoupled.
|
386
388
|
|
@@ -417,6 +419,7 @@ Search::User.adults.active_records(User.where(active: true))
|
|
417
419
|
```
|
418
420
|
|
419
421
|
## Upgrading from 0.7.0 to 0.8.0
|
422
|
+
|
420
423
|
The default persistence strategy changed from SingleIndex to AliasIndex in version 0.8.0 Add the following to your Document configuration to maintain the legacy behaviour.
|
421
424
|
|
422
425
|
```ruby
|
@@ -424,6 +427,7 @@ The default persistence strategy changed from SingleIndex to AliasIndex in versi
|
|
424
427
|
```
|
425
428
|
|
426
429
|
## Roadmap
|
430
|
+
|
427
431
|
- [ ] Define from_active_record interface
|
428
432
|
- [ ] Write more detailed documentation section for:
|
429
433
|
- [ ] Model definition
|
@@ -436,12 +440,12 @@ The default persistence strategy changed from SingleIndex to AliasIndex in versi
|
|
436
440
|
|
437
441
|
## Contributing
|
438
442
|
|
439
|
-
1.
|
440
|
-
2.
|
441
|
-
3.
|
442
|
-
4.
|
443
|
-
5.
|
444
|
-
6.
|
443
|
+
1. See [CONTRIBUTING.md](./CONTRIBUTING.md)
|
444
|
+
2. Fork it ( https://github.com/[my-github-username]/elasticity/fork )
|
445
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
446
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
447
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
448
|
+
6. Create a new Pull Request
|
445
449
|
|
446
450
|
## Gem documentation
|
447
451
|
|
data/es-elasticity.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "elasticity/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "es-elasticity"
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler", "~>
|
24
|
+
spec.add_development_dependency "bundler", "~> 2.3.4"
|
25
25
|
spec.add_development_dependency "byebug"
|
26
26
|
spec.add_development_dependency "codeclimate-test-reporter"
|
27
27
|
spec.add_development_dependency "oj"
|
@@ -33,8 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "simplecov", "~> 0.7.1"
|
34
34
|
spec.add_development_dependency "timecop"
|
35
35
|
|
36
|
-
spec.add_dependency "activemodel", ">=
|
37
|
-
spec.add_dependency "activerecord", ">=
|
38
|
-
spec.add_dependency "activesupport", ">=
|
39
|
-
spec.add_dependency "elasticsearch", ">=
|
36
|
+
spec.add_dependency "activemodel", ">= 5.2.0", "< 7.1"
|
37
|
+
spec.add_dependency "activerecord", ">= 5.2.0", "< 7.1"
|
38
|
+
spec.add_dependency "activesupport", ">= 5.2.0", "< 7.1"
|
39
|
+
spec.add_dependency "elasticsearch", ">= 7", "< 8"
|
40
40
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Elasticity
|
2
4
|
class BaseDocument
|
3
5
|
include ::ActiveModel::Model
|
@@ -60,7 +62,7 @@ module Elasticity
|
|
60
62
|
end
|
61
63
|
|
62
64
|
def self.default_document_type
|
63
|
-
self.name.gsub(
|
65
|
+
self.name.gsub("::", "_").underscore
|
64
66
|
end
|
65
67
|
|
66
68
|
def self.default_index_base_name
|