chewy 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -4
- data/lib/chewy/config.rb +47 -1
- data/lib/chewy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f677d05031da075087c0fb9942f31741766ce341
|
4
|
+
data.tar.gz: 5759eead057c0e533a988ce96e5dd1c77ab9ccd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76d493cea3e5fd380fc455e53fe886a16e48a1d1050f619668617f719d7721dd3cd93ae1b815bec5785142a5bf7f3d327e3dbc2e4db3a8a8cee521ed61ee93fc
|
7
|
+
data.tar.gz: 3091372369882b60d33b5b2ca8928a81ff1b9e7f5c7d8ff38fb0518bbb4a8d4e431746594e78d34a193c58c4aebff0bc245bc6be2ee27f046ca863e2988027a8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -7,8 +7,6 @@ Chewy is ODM and wrapper for official elasticsearch client (https://github.com/e
|
|
7
7
|
|
8
8
|
## Why chewy?
|
9
9
|
|
10
|
-
|
11
|
-
|
12
10
|
* Multi-model indexes.
|
13
11
|
|
14
12
|
Index classes are independant from ORM/ODM models. Now implementing, e.g. cross-model autocomplete is much easier. You can just define index and work with it in object-oriented style. You can define several types for index - one per indexed model.
|
@@ -64,7 +62,7 @@ The result config merges both hashes. Client options are passed as is to Elastic
|
|
64
62
|
|
65
63
|
```ruby
|
66
64
|
Chewy.configuration = {prefix: 'testing'}
|
67
|
-
UsersIndex.index_name # => '
|
65
|
+
UsersIndex.index_name # => 'test_users'
|
68
66
|
```
|
69
67
|
|
70
68
|
Also logger might be set explicitly:
|
@@ -73,6 +71,8 @@ Also logger might be set explicitly:
|
|
73
71
|
Chewy.logger = Logger.new
|
74
72
|
```
|
75
73
|
|
74
|
+
See [config.rb](lib/chewy/config.rb) for more details.
|
75
|
+
|
76
76
|
### Index definition
|
77
77
|
|
78
78
|
1. Create `/app/chewy/users_index.rb`
|
@@ -229,7 +229,9 @@ See [actions.rb](lib/chewy/index/actions.rb) for more details.
|
|
229
229
|
|
230
230
|
### Observing strategies
|
231
231
|
|
232
|
-
There are 3 strategies for index updating: do not update index at all, update right after save and
|
232
|
+
There are 3 strategies for index updating: do not update index at all, update right after save and cumulative update. The first is by default.
|
233
|
+
|
234
|
+
**WARN: It is preferred to use `Chewy.atomic` block in most cases due to performance restrictions of the urgent updates!**
|
233
235
|
|
234
236
|
#### Updating index on-demand
|
235
237
|
|
data/lib/chewy/config.rb
CHANGED
@@ -63,6 +63,49 @@ module Chewy
|
|
63
63
|
#
|
64
64
|
repository :char_filter
|
65
65
|
|
66
|
+
# Chewy core configurations. There is two ways to set it up:
|
67
|
+
# use `Chewy.configuration=` method or, for Rails application,
|
68
|
+
# create `config/chewy.yml` file. Btw, `config/chewy.yml` supports
|
69
|
+
# ERB the same way as ActiveRecord's config.
|
70
|
+
#
|
71
|
+
# Configuration options:
|
72
|
+
#
|
73
|
+
# 1. Chewy client options. All the options Elasticsearch::Client
|
74
|
+
# supports.
|
75
|
+
#
|
76
|
+
# test:
|
77
|
+
# host: 'localhost:9250'
|
78
|
+
#
|
79
|
+
# 2. Chewy self-configuration:
|
80
|
+
#
|
81
|
+
# :prefix - used as prefix for any index created.
|
82
|
+
#
|
83
|
+
# test:
|
84
|
+
# host: 'localhost:9250'
|
85
|
+
# prefix: test<%= ENV['TEST_ENV_NUMBER'] %>
|
86
|
+
#
|
87
|
+
# Then UsersIndex.index_name will be "test42_users"
|
88
|
+
# in case TEST_ENV_NUMBER=42
|
89
|
+
#
|
90
|
+
# :wait_for_status - if this option set - chewy actions such
|
91
|
+
# as creating or deleting index, importing data will wait for
|
92
|
+
# the status specified. Extremely useful for tests under havy
|
93
|
+
# indexes manipulations.
|
94
|
+
#
|
95
|
+
# test:
|
96
|
+
# host: 'localhost:9250'
|
97
|
+
# wait_for_status: green
|
98
|
+
#
|
99
|
+
# 3. Index settings. All the possible ElasticSearch index settings.
|
100
|
+
# Will be merged as defaults with index settings on every index
|
101
|
+
# creation.
|
102
|
+
#
|
103
|
+
# test: &test
|
104
|
+
# host: 'localhost:9250'
|
105
|
+
# index:
|
106
|
+
# number_of_shards: 1
|
107
|
+
# number_of_replicas: 0
|
108
|
+
#
|
66
109
|
def configuration
|
67
110
|
options = @configuration.deep_symbolize_keys.merge(yaml_options)
|
68
111
|
options.merge!(logger: logger) if logger
|
@@ -105,7 +148,10 @@ module Chewy
|
|
105
148
|
@yaml_options ||= begin
|
106
149
|
if defined?(Rails)
|
107
150
|
file = Rails.root.join(*%w(config chewy.yml))
|
108
|
-
|
151
|
+
if File.exists?(file)
|
152
|
+
yaml = ERB.new(File.read(file)).result
|
153
|
+
YAML.load(yaml)[Rails.env].try(:deep_symbolize_keys)
|
154
|
+
end
|
109
155
|
end || {}
|
110
156
|
end
|
111
157
|
end
|
data/lib/chewy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyromaniac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|