chewy 5.0.0 → 7.0.1
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 +240 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +16 -0
- data/.github/workflows/ruby.yml +94 -0
- data/Appraisals +1 -17
- data/CHANGELOG.md +308 -356
- data/CODE_OF_CONDUCT.md +14 -0
- data/CONTRIBUTING.md +63 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +71 -55
- data/chewy.gemspec +5 -5
- data/gemfiles/rails.5.2.activerecord.gemfile +4 -3
- data/gemfiles/{rails.5.0.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +4 -3
- data/gemfiles/{rails.5.0.mongoid.6.1.gemfile → rails.6.0.activerecord.gemfile} +4 -3
- data/gemfiles/{rails.5.1.activerecord.gemfile → rails.6.1.activerecord.gemfile} +6 -3
- data/lib/chewy.rb +1 -1
- data/lib/chewy/backports/duplicable.rb +1 -1
- data/lib/chewy/config.rb +2 -20
- data/lib/chewy/fields/base.rb +1 -7
- data/lib/chewy/fields/root.rb +2 -2
- data/lib/chewy/index.rb +2 -0
- data/lib/chewy/index/actions.rb +15 -5
- data/lib/chewy/index/aliases.rb +16 -5
- data/lib/chewy/multi_search.rb +62 -0
- data/lib/chewy/railtie.rb +1 -1
- data/lib/chewy/search.rb +2 -9
- data/lib/chewy/search/loader.rb +1 -1
- data/lib/chewy/search/pagination/will_paginate.rb +1 -1
- data/lib/chewy/search/parameters.rb +24 -6
- data/lib/chewy/search/parameters/allow_partial_search_results.rb +27 -0
- data/lib/chewy/search/parameters/indices.rb +123 -0
- data/lib/chewy/search/parameters/none.rb +1 -3
- data/lib/chewy/search/request.rb +101 -74
- data/lib/chewy/search/scrolling.rb +7 -6
- data/lib/chewy/stash.rb +1 -1
- data/lib/chewy/strategy/active_job.rb +1 -1
- data/lib/chewy/strategy/sidekiq.rb +1 -1
- data/lib/chewy/type.rb +4 -1
- data/lib/chewy/type/adapter/active_record.rb +1 -1
- data/lib/chewy/type/adapter/mongoid.rb +1 -1
- data/lib/chewy/type/adapter/orm.rb +7 -4
- data/lib/chewy/type/adapter/sequel.rb +1 -1
- data/lib/chewy/type/import.rb +14 -4
- data/lib/chewy/type/import/bulk_request.rb +4 -2
- data/lib/chewy/type/import/journal_builder.rb +1 -1
- data/lib/chewy/type/import/routine.rb +1 -1
- data/lib/chewy/type/mapping.rb +4 -4
- data/lib/chewy/type/observe.rb +3 -3
- data/lib/chewy/type/syncer.rb +4 -5
- data/lib/chewy/type/witchcraft.rb +4 -2
- data/lib/chewy/type/wrapper.rb +12 -2
- data/lib/chewy/version.rb +1 -1
- data/migration_guide.md +56 -0
- data/spec/chewy/config_spec.rb +1 -22
- data/spec/chewy/fields/base_spec.rb +11 -9
- data/spec/chewy/index/actions_spec.rb +120 -33
- data/spec/chewy/index/aliases_spec.rb +3 -3
- data/spec/chewy/index_spec.rb +16 -39
- data/spec/chewy/journal_spec.rb +22 -18
- data/spec/chewy/minitest/search_index_receiver_spec.rb +11 -9
- data/spec/chewy/multi_search_spec.rb +85 -0
- data/spec/chewy/rake_helper_spec.rb +102 -87
- data/spec/chewy/rspec/update_index_spec.rb +47 -46
- data/spec/chewy/runtime_spec.rb +2 -2
- data/spec/chewy/search/parameters/indices_spec.rb +190 -0
- data/spec/chewy/search/parameters/none_spec.rb +1 -1
- data/spec/chewy/search/parameters_spec.rb +21 -4
- data/spec/chewy/search/request_spec.rb +103 -70
- data/spec/chewy/search/response_spec.rb +27 -17
- data/spec/chewy/search/scrolling_spec.rb +27 -17
- data/spec/chewy/search_spec.rb +45 -41
- data/spec/chewy/stash_spec.rb +14 -12
- data/spec/chewy/strategy/active_job_spec.rb +15 -2
- data/spec/chewy/strategy/shoryuken_spec.rb +6 -2
- data/spec/chewy/strategy/sidekiq_spec.rb +6 -2
- data/spec/chewy/type/adapter/active_record_spec.rb +16 -4
- data/spec/chewy/type/import/bulk_builder_spec.rb +9 -94
- data/spec/chewy/type/import/journal_builder_spec.rb +9 -7
- data/spec/chewy/type/import_spec.rb +9 -0
- data/spec/chewy/type/mapping_spec.rb +3 -1
- data/spec/chewy/type/observe_spec.rb +4 -4
- data/spec/chewy/type/witchcraft_spec.rb +15 -0
- data/spec/chewy/type/wrapper_spec.rb +3 -1
- data/spec/chewy_spec.rb +0 -7
- data/spec/spec_helper.rb +4 -8
- data/spec/support/active_record.rb +21 -0
- metadata +32 -97
- data/.travis.yml +0 -45
- data/LEGACY_DSL.md +0 -497
- data/gemfiles/rails.4.0.activerecord.gemfile +0 -15
- data/gemfiles/rails.4.1.activerecord.gemfile +0 -15
- data/gemfiles/rails.4.2.activerecord.gemfile +0 -16
- data/gemfiles/rails.4.2.mongoid.5.2.gemfile +0 -16
- data/gemfiles/rails.5.1.mongoid.6.3.gemfile +0 -16
- data/lib/chewy/query.rb +0 -1137
- data/lib/chewy/query/compose.rb +0 -68
- data/lib/chewy/query/criteria.rb +0 -191
- data/lib/chewy/query/filters.rb +0 -244
- data/lib/chewy/query/loading.rb +0 -110
- data/lib/chewy/query/nodes/and.rb +0 -25
- data/lib/chewy/query/nodes/base.rb +0 -17
- data/lib/chewy/query/nodes/bool.rb +0 -34
- data/lib/chewy/query/nodes/equal.rb +0 -34
- data/lib/chewy/query/nodes/exists.rb +0 -20
- data/lib/chewy/query/nodes/expr.rb +0 -28
- data/lib/chewy/query/nodes/field.rb +0 -110
- data/lib/chewy/query/nodes/has_child.rb +0 -15
- data/lib/chewy/query/nodes/has_parent.rb +0 -15
- data/lib/chewy/query/nodes/has_relation.rb +0 -59
- data/lib/chewy/query/nodes/match_all.rb +0 -11
- data/lib/chewy/query/nodes/missing.rb +0 -20
- data/lib/chewy/query/nodes/not.rb +0 -25
- data/lib/chewy/query/nodes/or.rb +0 -25
- data/lib/chewy/query/nodes/prefix.rb +0 -19
- data/lib/chewy/query/nodes/query.rb +0 -20
- data/lib/chewy/query/nodes/range.rb +0 -63
- data/lib/chewy/query/nodes/raw.rb +0 -15
- data/lib/chewy/query/nodes/regexp.rb +0 -35
- data/lib/chewy/query/nodes/script.rb +0 -20
- data/lib/chewy/query/pagination.rb +0 -25
- data/spec/chewy/query/criteria_spec.rb +0 -700
- data/spec/chewy/query/filters_spec.rb +0 -201
- data/spec/chewy/query/loading_spec.rb +0 -124
- data/spec/chewy/query/nodes/and_spec.rb +0 -12
- data/spec/chewy/query/nodes/bool_spec.rb +0 -14
- data/spec/chewy/query/nodes/equal_spec.rb +0 -32
- data/spec/chewy/query/nodes/exists_spec.rb +0 -18
- data/spec/chewy/query/nodes/has_child_spec.rb +0 -59
- data/spec/chewy/query/nodes/has_parent_spec.rb +0 -59
- data/spec/chewy/query/nodes/match_all_spec.rb +0 -11
- data/spec/chewy/query/nodes/missing_spec.rb +0 -16
- data/spec/chewy/query/nodes/not_spec.rb +0 -14
- data/spec/chewy/query/nodes/or_spec.rb +0 -12
- data/spec/chewy/query/nodes/prefix_spec.rb +0 -16
- data/spec/chewy/query/nodes/query_spec.rb +0 -12
- data/spec/chewy/query/nodes/range_spec.rb +0 -32
- data/spec/chewy/query/nodes/raw_spec.rb +0 -11
- data/spec/chewy/query/nodes/regexp_spec.rb +0 -43
- data/spec/chewy/query/nodes/script_spec.rb +0 -15
- data/spec/chewy/query/pagination/kaminari_spec.rb +0 -5
- data/spec/chewy/query/pagination/will_paginate_spec.rb +0 -5
- data/spec/chewy/query/pagination_spec.rb +0 -39
- data/spec/chewy/query_spec.rb +0 -637
- data/spec/chewy/search/parameters/indices_boost_spec.rb +0 -83
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# The Chewy Community Code of Conduct
|
2
|
+
|
3
|
+
**Note:** We have picked the following code of conduct based on [Ruby's own code of conduct](https://www.ruby-lang.org/en/conduct/).
|
4
|
+
|
5
|
+
This document provides a few simple community guidelines for a safe, respectful,
|
6
|
+
productive, and collaborative place for any person who is willing to contribute
|
7
|
+
to the Chewy community. It applies to all "collaborative spaces", which are
|
8
|
+
defined as community communications channels (such as mailing lists, submitted
|
9
|
+
patches, commit comments, etc.).
|
10
|
+
|
11
|
+
* Participants will be tolerant of opposing views.
|
12
|
+
* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
|
13
|
+
* When interpreting the words and actions of others, participants should always assume good intentions.
|
14
|
+
* Behaviour which can be reasonably considered harassment will not be tolerated.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
If you discover issues, have ideas for improvements or new features,
|
4
|
+
please report them to the [issue tracker][1] of the repository or
|
5
|
+
submit a pull request. Please, try to follow these guidelines when you
|
6
|
+
do so.
|
7
|
+
|
8
|
+
## Issue reporting
|
9
|
+
|
10
|
+
* Check that the issue has not already been reported.
|
11
|
+
* Check that the issue has not already been fixed in the latest code
|
12
|
+
(a.k.a. `master`).
|
13
|
+
* Be clear, concise and precise in your description of the problem.
|
14
|
+
* Open an issue with a descriptive title and a summary in grammatically correct,
|
15
|
+
complete sentences.
|
16
|
+
* Include the versions of Chewy, Elasticsearch, Ruby, Rails, etc.
|
17
|
+
* Include any relevant code to the issue summary.
|
18
|
+
|
19
|
+
## Pull requests
|
20
|
+
|
21
|
+
* Read [how to properly contribute to open source projects on GitHub][2].
|
22
|
+
* Fork the project.
|
23
|
+
* Use a topic/feature branch to easily amend a pull request later, if necessary.
|
24
|
+
* Write [good commit messages][3].
|
25
|
+
* Use the same coding conventions as the rest of the project.
|
26
|
+
* Commit and push until you are happy with your contribution.
|
27
|
+
* If your change has a corresponding open GitHub issue, prefix the commit message with `[Fix #github-issue-number]`.
|
28
|
+
* Make sure to add tests for it. This is important so I don't break it
|
29
|
+
in a future version unintentionally.
|
30
|
+
* Add an entry to the [Changelog](CHANGELOG.md).
|
31
|
+
* Please try not to mess with the Rakefile, version, or history. If
|
32
|
+
you want to have your own version, or is otherwise necessary, that
|
33
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
34
|
+
around it.
|
35
|
+
* Make sure the test suite is passing and the code you wrote doesn't produce
|
36
|
+
RuboCop offenses.
|
37
|
+
* [Squash related commits together][5].
|
38
|
+
* Open a [pull request][4] that relates to *only* one subject with a clear title
|
39
|
+
and description in grammatically correct, complete sentences.
|
40
|
+
|
41
|
+
## Changelog entry format
|
42
|
+
|
43
|
+
Here are a few examples:
|
44
|
+
|
45
|
+
```
|
46
|
+
* [#753](https://github.com/toptal/chewy/pull/753): Add support for direct_import parameter to skip objects reloading. ([@TikiTDO][], [@dalthon][])
|
47
|
+
* [#739](https://github.com/toptal/chewy/pull/739): Remove explicit `main` branch dependencies on `rspec-*` gems after `rspec-mocks` 3.10.2 is released. ([@rabotyaga][])
|
48
|
+
```
|
49
|
+
|
50
|
+
* Mark it up in [Markdown syntax][6].
|
51
|
+
* The entry line should start with `* ` (an asterisk and a space).
|
52
|
+
* If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#123](https://github.com/toptal/chewy/issues/123): `.
|
53
|
+
* Describe the brief of the change. The sentence should end with a punctuation.
|
54
|
+
* If this is a breaking change, mark it with `**(Breaking)**`.
|
55
|
+
* At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
|
56
|
+
* If this is your first contribution to the project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`.
|
57
|
+
|
58
|
+
[1]: https://github.com/toptal/chewy/issues
|
59
|
+
[2]: https://www.gun.io/blog/how-to-github-fork-branch-and-pull-request
|
60
|
+
[3]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
61
|
+
[4]: https://help.github.com/articles/about-pull-requests
|
62
|
+
[5]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
|
63
|
+
[6]: https://daringfireball.net/projects/markdown/syntax
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/chewy.svg)](http://badge.fury.io/rb/chewy)
|
2
|
-
[![
|
2
|
+
[![CircleCI](https://circleci.com/gh/toptal/chewy/tree/master.svg?style=svg)](https://circleci.com/gh/toptal/chewy/tree/master)
|
3
3
|
[![Code Climate](https://codeclimate.com/github/toptal/chewy.svg)](https://codeclimate.com/github/toptal/chewy)
|
4
4
|
[![Inline docs](http://inch-ci.org/github/toptal/chewy.svg?branch=master)](http://inch-ci.org/github/toptal/chewy)
|
5
5
|
|
6
|
-
<p align="right">Sponsored by</p>
|
7
|
-
<p align="right"><a href="https://www.toptal.com/"><img src="https://www.toptal.com/assets/public/blocks/logo/big.png" alt="Toptal" width="105" height="34"></a></p>
|
8
|
-
|
9
6
|
# Chewy
|
10
7
|
|
11
|
-
Chewy is an ODM
|
8
|
+
Chewy is an ODM (Object Document Mapper), built on top of the [the official Elasticsearch client](https://github.com/elastic/elasticsearch-ruby).
|
12
9
|
|
13
10
|
## Table of Contents
|
14
11
|
|
@@ -34,7 +31,7 @@ Chewy is an ODM and wrapper for [the official Elasticsearch client](https://gith
|
|
34
31
|
* [Non-block notation](#non-block-notation)
|
35
32
|
* [Designing your own strategies](#designing-your-own-strategies)
|
36
33
|
* [Rails application strategies integration](#rails-application-strategies-integration)
|
37
|
-
* [ActiveSupport::Notifications support](#
|
34
|
+
* [ActiveSupport::Notifications support](#activesupportnotifications-support)
|
38
35
|
* [NewRelic integration](#newrelic-integration)
|
39
36
|
* [Search requests](#search-requests)
|
40
37
|
* [Composing requests](#composing-requests)
|
@@ -42,7 +39,6 @@ Chewy is an ODM and wrapper for [the official Elasticsearch client](https://gith
|
|
42
39
|
* [Named scopes](#named-scopes)
|
43
40
|
* [Scroll API](#scroll-api)
|
44
41
|
* [Loading objects](#loading-objects)
|
45
|
-
* [Legacy DSL incompatibilities](#legacy-dsl-incompatibilities)
|
46
42
|
* [Rake tasks](#rake-tasks)
|
47
43
|
* [chewy:reset](#chewyreset)
|
48
44
|
* [chewy:upgrade](#chewyupgrade)
|
@@ -51,13 +47,14 @@ Chewy is an ODM and wrapper for [the official Elasticsearch client](https://gith
|
|
51
47
|
* [chewy:deploy](#chewydeploy)
|
52
48
|
* [Parallelizing rake tasks](#parallelizing-rake-tasks)
|
53
49
|
* [chewy:journal](#chewyjournal)
|
54
|
-
* [
|
50
|
+
* [RSpec integration](#rspec-integration)
|
55
51
|
* [Minitest integration](#minitest-integration)
|
56
|
-
* [TODO a.k.a coming soon](#todo-aka-coming-soon)
|
57
52
|
* [Contributing](#contributing)
|
58
53
|
|
59
54
|
## Why Chewy?
|
60
55
|
|
56
|
+
In this section we'll cover why you might want to use Chewy instead of the official `elasticsearch-ruby` client gem.
|
57
|
+
|
61
58
|
* Multi-model indices.
|
62
59
|
|
63
60
|
Index classes are independent from ORM/ODM models. Now, implementing e.g. cross-model autocomplete is much easier. You can just define the index and work with it in an object-oriented style. You can define several types for index - one per indexed model.
|
@@ -76,10 +73,9 @@ Chewy is an ODM and wrapper for [the official Elasticsearch client](https://gith
|
|
76
73
|
|
77
74
|
* Support for ActiveRecord, [Mongoid](https://github.com/mongoid/mongoid) and [Sequel](https://github.com/jeremyevans/sequel).
|
78
75
|
|
79
|
-
|
80
76
|
## Installation
|
81
77
|
|
82
|
-
Add this line to your application's Gemfile
|
78
|
+
Add this line to your application's `Gemfile`:
|
83
79
|
|
84
80
|
gem 'chewy'
|
85
81
|
|
@@ -91,13 +87,35 @@ Or install it yourself as:
|
|
91
87
|
|
92
88
|
$ gem install chewy
|
93
89
|
|
90
|
+
## Compatibility
|
91
|
+
|
92
|
+
### Ruby
|
93
|
+
|
94
|
+
Chewy is compatible with MRI 2.5-3.0¹.
|
95
|
+
|
96
|
+
> ¹ Ruby 3 is only supported with Rails 6.1
|
97
|
+
|
98
|
+
### Elasticsearch compatibility matrix
|
99
|
+
|
100
|
+
| Chewy version | Elasticsearch version |
|
101
|
+
| ------------- | ---------------------------------- |
|
102
|
+
| 7.0.0 | 6.8, 7.x |
|
103
|
+
| 6.0.0 | 5.x, 6.x |
|
104
|
+
| 5.x | 5.x, limited support for 1.x & 2.x |
|
105
|
+
|
106
|
+
See [Migration guide](migration_guide.md).
|
107
|
+
|
94
108
|
## Usage
|
95
109
|
|
96
110
|
### Client settings
|
97
111
|
|
98
|
-
There are two ways to configure the Chewy client:
|
112
|
+
There are two ways to configure the Chewy client:
|
99
113
|
|
100
|
-
|
114
|
+
* via the hash `Chewy.settings`
|
115
|
+
* via the configuration file `chewy.yml`
|
116
|
+
|
117
|
+
You can create `chewy.yml` manually or run `rails g chewy:install` to
|
118
|
+
generate it.
|
101
119
|
|
102
120
|
```ruby
|
103
121
|
# config/initializers/chewy.rb
|
@@ -129,25 +147,29 @@ Chewy.logger = Logger.new(STDOUT)
|
|
129
147
|
|
130
148
|
See [config.rb](lib/chewy/config.rb) for more details.
|
131
149
|
|
132
|
-
####
|
133
|
-
|
150
|
+
#### AWS Elasticsearch
|
151
|
+
|
152
|
+
If you would like to use AWS's Elasticsearch using an IAM user policy, you will need to sign your requests for the `es:*` action by injecting the appropriate headers passing a proc to `transport_options`.
|
153
|
+
You'll need an additional gem for Faraday middleware: add `gem 'faraday_middleware-aws-sigv4'` to your Gemfile.
|
134
154
|
|
135
155
|
```ruby
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
156
|
+
require 'faraday_middleware/aws_sigv4'
|
157
|
+
|
158
|
+
Chewy.settings = {
|
159
|
+
host: 'http://my-es-instance-on-aws.us-east-1.es.amazonaws.com:80',
|
160
|
+
port: 80, # 443 for https host
|
161
|
+
transport_options: {
|
162
|
+
headers: { content_type: 'application/json' },
|
163
|
+
proc: -> (f) do
|
164
|
+
f.request :aws_sigv4,
|
165
|
+
service: 'es',
|
166
|
+
region: 'us-east-1',
|
167
|
+
access_key_id: ENV['AWS_ACCESS_KEY'],
|
168
|
+
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
169
|
+
end
|
149
170
|
}
|
150
|
-
|
171
|
+
}
|
172
|
+
```
|
151
173
|
|
152
174
|
### Index definition
|
153
175
|
|
@@ -180,7 +202,7 @@ If you would like to use AWS's ElasticSearch using an IAM user policy, you will
|
|
180
202
|
field :badges, value: ->(user) { user.badges.map(&:name) } # passing array values to index
|
181
203
|
field :projects do # the same block syntax for multi_field, if `:type` is specified
|
182
204
|
field :title
|
183
|
-
field :description # default data type is `
|
205
|
+
field :description # default data type is `text`
|
184
206
|
# additional top-level objects passed to value proc:
|
185
207
|
field :categories, value: ->(project, user) { project.categories.map(&:name) if user.active? }
|
186
208
|
end
|
@@ -337,7 +359,7 @@ To define a multi field you have to specify any type except for `object` or `nes
|
|
337
359
|
```ruby
|
338
360
|
field :full_name, type: 'text', value: ->{ full_name.strip } do
|
339
361
|
field :ordered, analyzer: 'ordered'
|
340
|
-
field :untouched,
|
362
|
+
field :untouched, type: 'keyword'
|
341
363
|
end
|
342
364
|
```
|
343
365
|
|
@@ -678,6 +700,11 @@ Chewy.strategy(:sidekiq) do
|
|
678
700
|
end
|
679
701
|
```
|
680
702
|
|
703
|
+
The default queue name is `chewy`, you can customize it in settings: `sidekiq.queue_name`
|
704
|
+
```
|
705
|
+
Chewy.settings[:sidekiq] = {queue: :low}
|
706
|
+
```
|
707
|
+
|
681
708
|
#### `:active_job`
|
682
709
|
|
683
710
|
This does the same thing as `:atomic`, but using ActiveJob. This will inherit the ActiveJob configuration settings including the `active_job.queue_adapter` setting for the environment. Patch `Chewy::Strategy::ActiveJob::Worker` for index updates improving.
|
@@ -688,6 +715,11 @@ Chewy.strategy(:active_job) do
|
|
688
715
|
end
|
689
716
|
```
|
690
717
|
|
718
|
+
The default queue name is `chewy`, you can customize it in settings: `active_job.queue_name`
|
719
|
+
```
|
720
|
+
Chewy.settings[:active_job] = {queue: :low}
|
721
|
+
```
|
722
|
+
|
691
723
|
#### `:shoryuken`
|
692
724
|
|
693
725
|
This does the same thing as `:atomic`, but asynchronously using shoryuken. Patch `Chewy::Strategy::Shoryuken::Worker` for index updates improving.
|
@@ -884,11 +916,7 @@ ActiveSupport::Notifications.subscribe(/.chewy$/, ChewySubscriber.new)
|
|
884
916
|
|
885
917
|
### Search requests
|
886
918
|
|
887
|
-
|
888
|
-
|
889
|
-
If you want to use the old DSL - simply do `Chewy.search_class = Chewy::Query` somewhere before indices are initialized.
|
890
|
-
|
891
|
-
The new DSL is enabled by default, here is a quick introduction.
|
919
|
+
Quick introduction.
|
892
920
|
|
893
921
|
#### Composing requests
|
894
922
|
|
@@ -956,17 +984,6 @@ scope.each do |wrapper|
|
|
956
984
|
end
|
957
985
|
```
|
958
986
|
|
959
|
-
#### Legacy DSL incompatibilities
|
960
|
-
|
961
|
-
* Filters advanced block DSL is not supported anymore, `elasticsearch-dsl` is used instead.
|
962
|
-
* Things like `query_mode` and `filter_mode` are in past, use advanced DSL to achieve similar behavior. See [Chewy::Search::QueryProxy](lib/chewy/search/query_proxy.rb) for details.
|
963
|
-
* `preload` method is no more, the collection returned by scope doesn't depend on loading options, scope always returns `Chewy::Type` wrappers. To get ORM/ODM objects, use `#objects` method.
|
964
|
-
* Some of the methods have changed their purpose: `only` was used to filter fields before, now it filters the scope. To filter fields use `source` or `stored_fields`.
|
965
|
-
* `types!` method is no more, use `except(:types).types(...)`
|
966
|
-
* Named aggregations are not supported, use named scopes instead.
|
967
|
-
* A lot of query-level methods were not ported: everything that is related to boost and scoring. Use `query` manipulation to provide them.
|
968
|
-
* `Chewy::Type#_object` returns nil always. Use `Chewy::Search::Response#object_hash` instead.
|
969
|
-
|
970
987
|
### Rake tasks
|
971
988
|
|
972
989
|
For a Rails application, some index-maintaining rake tasks are defined.
|
@@ -1013,7 +1030,7 @@ rake chewy:update[-users,places#city] # updates every index in the application e
|
|
1013
1030
|
|
1014
1031
|
#### `chewy:sync`
|
1015
1032
|
|
1016
|
-
Provides a way to synchronize outdated indexes with the source quickly and without doing a full reset.
|
1033
|
+
Provides a way to synchronize outdated indexes with the source quickly and without doing a full reset. By default field `updated_at` is used to find outdated records, but this could be customized by `outdated_sync_field` as described at [Chewy::Type::Syncer](lib/chewy/type/syncer.rb).
|
1017
1034
|
|
1018
1035
|
Arguments are similar to the ones taken by `chewy:update` task. It is possible to specify a particular type or a whole index.
|
1019
1036
|
|
@@ -1061,7 +1078,7 @@ rake chewy:journal:apply["$(date -v-1H -u +%FT%TZ)"] # apply journaled changes f
|
|
1061
1078
|
rake chewy:journal:apply["$(date -v-1H -u +%FT%TZ)",users] # apply journaled changes for the past hour on UsersIndex only
|
1062
1079
|
```
|
1063
1080
|
|
1064
|
-
###
|
1081
|
+
### RSpec integration
|
1065
1082
|
|
1066
1083
|
Just add `require 'chewy/rspec'` to your spec_helper.rb and you will get additional features: See [update_index.rb](lib/chewy/rspec/update_index.rb) for more details.
|
1067
1084
|
|
@@ -1082,12 +1099,6 @@ If you use `DatabaseCleaner` in your tests with [the `transaction` strategy](htt
|
|
1082
1099
|
Chewy.use_after_commit_callbacks = !Rails.env.test?
|
1083
1100
|
```
|
1084
1101
|
|
1085
|
-
## TODO a.k.a coming soon:
|
1086
|
-
|
1087
|
-
* Typecasting support
|
1088
|
-
* update_all support
|
1089
|
-
* Maybe, closer ORM/ODM integration, creating index classes implicitly
|
1090
|
-
|
1091
1102
|
## Contributing
|
1092
1103
|
|
1093
1104
|
1. Fork it (http://github.com/toptal/chewy/fork)
|
@@ -1103,3 +1114,8 @@ Use the following Rake tasks to control the Elasticsearch cluster while developi
|
|
1103
1114
|
rake elasticsearch:start # start Elasticsearch cluster on 9250 port for tests
|
1104
1115
|
rake elasticsearch:stop # stop Elasticsearch
|
1105
1116
|
```
|
1117
|
+
|
1118
|
+
## Copyright
|
1119
|
+
|
1120
|
+
Copyright (c) 2013-2021 Toptal, LLC. See [LICENSE.txt](LICENSE.txt) for
|
1121
|
+
further details.
|
data/chewy.gemspec
CHANGED
@@ -5,8 +5,8 @@ require 'chewy/version'
|
|
5
5
|
Gem::Specification.new do |spec| # rubocop:disable BlockLength
|
6
6
|
spec.name = 'chewy'
|
7
7
|
spec.version = Chewy::VERSION
|
8
|
-
spec.authors = ['pyromaniac']
|
9
|
-
spec.email = ['kinwizard@gmail.com']
|
8
|
+
spec.authors = ['Toptal, LLC', 'pyromaniac']
|
9
|
+
spec.email = ['open-source@toptal.com', 'kinwizard@gmail.com']
|
10
10
|
spec.summary = 'Elasticsearch ODM client wrapper'
|
11
11
|
spec.description = 'Chewy provides functionality for Elasticsearch index handling, documents import mappings and chainable query DSL'
|
12
12
|
spec.homepage = 'https://github.com/toptal/chewy'
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec| # rubocop:disable BlockLength
|
|
22
22
|
spec.add_development_dependency 'elasticsearch-extensions'
|
23
23
|
spec.add_development_dependency 'rake'
|
24
24
|
spec.add_development_dependency 'resque_spec'
|
25
|
-
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency 'rspec', '>= 3.7.0'
|
26
26
|
spec.add_development_dependency 'rspec-collection_matchers'
|
27
27
|
spec.add_development_dependency 'rspec-its'
|
28
28
|
spec.add_development_dependency 'rubocop', '0.52.1'
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec| # rubocop:disable BlockLength
|
|
32
32
|
spec.add_development_dependency 'method_source'
|
33
33
|
spec.add_development_dependency 'unparser'
|
34
34
|
|
35
|
-
spec.add_dependency 'activesupport', '>=
|
36
|
-
spec.add_dependency 'elasticsearch', '>=
|
35
|
+
spec.add_dependency 'activesupport', '>= 5.2'
|
36
|
+
spec.add_dependency 'elasticsearch', '>= 6.3.0'
|
37
37
|
spec.add_dependency 'elasticsearch-dsl'
|
38
38
|
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~> 5.2.0
|
6
|
-
gem "activesupport", "~> 5.2.0
|
7
|
-
gem "activejob", "~> 5.2.0
|
5
|
+
gem "activerecord", "~> 5.2.0"
|
6
|
+
gem "activesupport", "~> 5.2.0"
|
7
|
+
gem "activejob", "~> 5.2.0"
|
8
8
|
gem "resque", require: false
|
9
9
|
gem "shoryuken", require: false
|
10
10
|
gem "aws-sdk-sqs", require: false
|
@@ -12,5 +12,6 @@ gem "sidekiq", require: false
|
|
12
12
|
gem "kaminari-core", "~> 1.1.0", require: false
|
13
13
|
gem "will_paginate", require: false
|
14
14
|
gem "parallel", require: false
|
15
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
15
16
|
|
16
17
|
gemspec path: "../"
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "
|
6
|
-
gem "activesupport", "~> 5.
|
7
|
-
gem "activejob", "~> 5.
|
5
|
+
gem "mongoid", "~> 6.4.0"
|
6
|
+
gem "activesupport", "~> 5.2.0"
|
7
|
+
gem "activejob", "~> 5.2.0"
|
8
8
|
gem "resque", require: false
|
9
9
|
gem "shoryuken", require: false
|
10
10
|
gem "aws-sdk-sqs", require: false
|
@@ -12,5 +12,6 @@ gem "sidekiq", require: false
|
|
12
12
|
gem "kaminari-core", "~> 1.1.0", require: false
|
13
13
|
gem "will_paginate", require: false
|
14
14
|
gem "parallel", require: false
|
15
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
15
16
|
|
16
17
|
gemspec path: "../"
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "
|
6
|
-
gem "activesupport", "~>
|
7
|
-
gem "activejob", "~>
|
5
|
+
gem "activerecord", "~> 6.0.0"
|
6
|
+
gem "activesupport", "~> 6.0.0"
|
7
|
+
gem "activejob", "~> 6.0.0"
|
8
8
|
gem "resque", require: false
|
9
9
|
gem "shoryuken", require: false
|
10
10
|
gem "aws-sdk-sqs", require: false
|
@@ -12,5 +12,6 @@ gem "sidekiq", require: false
|
|
12
12
|
gem "kaminari-core", "~> 1.1.0", require: false
|
13
13
|
gem "will_paginate", require: false
|
14
14
|
gem "parallel", require: false
|
15
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
15
16
|
|
16
17
|
gemspec path: "../"
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~>
|
6
|
-
gem "activesupport", "~>
|
7
|
-
gem "activejob", "~>
|
5
|
+
gem "activerecord", "~> 6.1.0"
|
6
|
+
gem "activesupport", "~> 6.1.0"
|
7
|
+
gem "activejob", "~> 6.1.0"
|
8
8
|
gem "resque", require: false
|
9
9
|
gem "shoryuken", require: false
|
10
10
|
gem "aws-sdk-sqs", require: false
|
@@ -12,5 +12,8 @@ gem "sidekiq", require: false
|
|
12
12
|
gem "kaminari-core", "~> 1.1.0", require: false
|
13
13
|
gem "will_paginate", require: false
|
14
14
|
gem "parallel", require: false
|
15
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
16
|
+
|
17
|
+
gem 'rexml' if RUBY_VERSION >= '3.0.0'
|
15
18
|
|
16
19
|
gemspec path: "../"
|