elasticsearch-rails 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/lib/elasticsearch/rails/instrumentation/publishers.rb +13 -15
- data/lib/elasticsearch/rails/version.rb +1 -1
- data/lib/rails/templates/03-expert.rb +8 -8
- data/lib/rails/templates/05-settings-files.rb +75 -0
- data/lib/rails/templates/articles_settings.json +1 -0
- data/lib/rails/templates/seeds.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 056008177dc6455f594126c6d1402930964812d9
|
4
|
+
data.tar.gz: 07c8b5cfaaa536c67648df8d9d24ecee62f5eed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d43e2b96ba3873e5b70652469d55a311537fba4cf9f020e6eec6638d816d3dc8e87c9b288b3fe9c1a5b285d1e57e022d09af23023d455902d9d8920e176a0395
|
7
|
+
data.tar.gz: a26d5d3fa224e6a7c7ff2752df9cf0c6ed8ec12a18a996c5d081ffa71437e3794fbede55cd010ab64647cd432953c7eedec45d52a4af967b222ee14d6f3359ed
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
|
1
|
+
## 0.1.8
|
2
|
+
|
3
|
+
* Added an example application template that loads settings from a file
|
4
|
+
* Added missing require in the seeds.rb file for the expert template
|
5
|
+
* Fixed double include of the aliased method (execute_without_instrumentation)
|
6
|
+
* Fixed the error when getting the search_controller_test.rb asset in `03-expert.rb` template
|
7
|
+
* Updated URLs for getting raw assets from Github in the `03-expert.rb` template
|
8
|
+
|
9
|
+
## 0.1.7
|
2
10
|
|
3
11
|
* Updated dependencies for the gem and example applications
|
4
12
|
* Fixed various small errors in the `01-basic.rb` template
|
@@ -12,25 +12,23 @@ module Elasticsearch
|
|
12
12
|
|
13
13
|
def self.included(base)
|
14
14
|
base.class_eval do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
execute_with_instrumentation!
|
19
|
-
end
|
20
|
-
|
21
|
-
# Wrap `Search#execute!` and perform instrumentation
|
22
|
-
#
|
23
|
-
def execute_with_instrumentation!
|
24
|
-
ActiveSupport::Notifications.instrument "search.elasticsearch",
|
25
|
-
name: 'Search',
|
26
|
-
klass: (self.klass.is_a?(Elasticsearch::Model::Proxy::ClassMethodsProxy) ? self.klass.target.to_s : self.klass.to_s),
|
27
|
-
search: self.definition do
|
28
|
-
execute_without_instrumentation!
|
29
|
-
end
|
15
|
+
unless method_defined?(:execute_without_instrumentation!)
|
16
|
+
alias_method :execute_without_instrumentation!, :execute!
|
17
|
+
alias_method :execute!, :execute_with_instrumentation!
|
30
18
|
end
|
31
19
|
end
|
32
20
|
end
|
33
21
|
|
22
|
+
# Wrap `Search#execute!` and perform instrumentation
|
23
|
+
#
|
24
|
+
def execute_with_instrumentation!
|
25
|
+
ActiveSupport::Notifications.instrument "search.elasticsearch",
|
26
|
+
name: 'Search',
|
27
|
+
klass: (self.klass.is_a?(Elasticsearch::Model::Proxy::ClassMethodsProxy) ? self.klass.target.to_s : self.klass.to_s),
|
28
|
+
search: self.definition do
|
29
|
+
execute_without_instrumentation!
|
30
|
+
end
|
31
|
+
end
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
@@ -157,7 +157,7 @@ CODE
|
|
157
157
|
gsub_file "#{Rails::VERSION::STRING > '4' ? 'test/models' : 'test/unit' }/article_test.rb", %r{assert_equal 'foo', definition\[:query\]\[:multi_match\]\[:query\]}, "assert_equal 'foo', definition.to_hash[:query][:bool][:should][0][:multi_match][:query]"
|
158
158
|
|
159
159
|
# copy_file File.expand_path('../searchable.rb', __FILE__), 'app/models/concerns/searchable.rb'
|
160
|
-
get 'https://raw.
|
160
|
+
get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/searchable.rb',
|
161
161
|
'app/models/concerns/searchable.rb'
|
162
162
|
|
163
163
|
insert_into_file "app/models/article.rb", after: "ActiveRecord::Base" do
|
@@ -186,7 +186,7 @@ gem "sidekiq"
|
|
186
186
|
run "bundle install"
|
187
187
|
|
188
188
|
# copy_file File.expand_path('../indexer.rb', __FILE__), 'app/workers/indexer.rb'
|
189
|
-
get 'https://raw.
|
189
|
+
get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/indexer.rb',
|
190
190
|
'app/workers/indexer.rb'
|
191
191
|
|
192
192
|
git add: "Gemfile* app/workers/"
|
@@ -217,19 +217,19 @@ create_file 'app/controllers/search_controller.rb' do
|
|
217
217
|
CODE
|
218
218
|
end
|
219
219
|
|
220
|
-
copy_file File.expand_path('../search_controller_test.rb', __FILE__), 'test/controllers/search_controller_test.rb'
|
221
|
-
|
220
|
+
# copy_file File.expand_path('../search_controller_test.rb', __FILE__), 'test/controllers/search_controller_test.rb'
|
221
|
+
get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/search_controller_test.rb',
|
222
222
|
'test/controllers/search_controller_test.rb'
|
223
223
|
|
224
224
|
route "get '/search', to: 'search#index', as: 'search'"
|
225
225
|
gsub_file 'config/routes.rb', %r{root to: 'articles#index'$}, "root to: 'search#index'"
|
226
226
|
|
227
227
|
# copy_file File.expand_path('../index.html.erb', __FILE__), 'app/views/search/index.html.erb'
|
228
|
-
get 'https://raw.
|
228
|
+
get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/index.html.erb',
|
229
229
|
'app/views/search/index.html.erb'
|
230
230
|
|
231
231
|
# copy_file File.expand_path('../search.css', __FILE__), 'app/assets/stylesheets/search.css'
|
232
|
-
get 'https://raw.
|
232
|
+
get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/search.css',
|
233
233
|
'app/assets/stylesheets/search.css'
|
234
234
|
|
235
235
|
git add: "app/controllers/ test/controllers/ config/routes.rb"
|
@@ -281,12 +281,12 @@ say_status "Database", "Re-creating the database with data and importing into E
|
|
281
281
|
puts '-'*80, ''; sleep 0.25
|
282
282
|
|
283
283
|
# copy_file File.expand_path('../articles.yml.gz', __FILE__), 'db/articles.yml.gz'
|
284
|
-
get 'https://raw.
|
284
|
+
get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/articles.yml.gz',
|
285
285
|
'db/articles.yml.gz'
|
286
286
|
|
287
287
|
remove_file 'db/seeds.rb'
|
288
288
|
# copy_file File.expand_path('../seeds.rb', __FILE__), 'db/seeds.rb'
|
289
|
-
get 'https://raw.
|
289
|
+
get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/seeds.rb',
|
290
290
|
'db/seeds.rb'
|
291
291
|
|
292
292
|
rake "db:reset"
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# $ rails new searchapp --skip --skip-bundle --template https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/05-settings-files.rb
|
2
|
+
|
3
|
+
# (See: 01-basic.rb, 02-pretty.rb, 03-expert.rb, 04-dsl.rb)
|
4
|
+
|
5
|
+
append_to_file 'README.rdoc', <<-README
|
6
|
+
|
7
|
+
== [5] Settings Files
|
8
|
+
|
9
|
+
The `settings-files` template refactors the `Searchable` module to load the index settings
|
10
|
+
from an external file.
|
11
|
+
|
12
|
+
README
|
13
|
+
|
14
|
+
git add: "README.rdoc"
|
15
|
+
git commit: "-m '[05] Updated the application README'"
|
16
|
+
|
17
|
+
# ----- Setup the Searchable module to load settings from config/elasticsearch/articles_settings.json
|
18
|
+
|
19
|
+
gsub_file "app/models/concerns/searchable.rb",
|
20
|
+
/index: { number_of_shards: 1, number_of_replicas: 0 }/,
|
21
|
+
"File.open('config/elasticsearch/articles_settings.json')"
|
22
|
+
|
23
|
+
git add: "app/models/concerns/searchable.rb"
|
24
|
+
git commit: "-m 'Setup the Searchable module to load settings from file'"
|
25
|
+
|
26
|
+
# ----- Copy the articles_settings.json file -------------------------------------------------------
|
27
|
+
|
28
|
+
copy_file File.expand_path('../articles_settings.json', __FILE__), 'config/elasticsearch/articles_settings.json'
|
29
|
+
|
30
|
+
git add: "config/elasticsearch/articles_settings.json"
|
31
|
+
git commit: "-m 'Create the articles settings file'"
|
32
|
+
|
33
|
+
# ----- Temporarily set local repo for testing ----------------------------------------------------
|
34
|
+
|
35
|
+
gsub_file "Gemfile",
|
36
|
+
%r{gem 'elasticsearch-model', git: 'git://github.com/elasticsearch/elasticsearch-rails.git'},
|
37
|
+
"gem 'elasticsearch-model', path: File.expand_path('../../../../../../elasticsearch-model', __FILE__)"
|
38
|
+
|
39
|
+
# ----- Run bundle install ------------------------------------------------------------------------
|
40
|
+
|
41
|
+
run "bundle install"
|
42
|
+
|
43
|
+
# ----- Recreate the index ------------------------------------------------------------------------
|
44
|
+
|
45
|
+
rake "environment elasticsearch:import:model CLASS='Article' BATCH=100 FORCE=y"
|
46
|
+
|
47
|
+
# ----- Print Git log -----------------------------------------------------------------------------
|
48
|
+
|
49
|
+
puts
|
50
|
+
say_status "Git", "Details about the application:", :yellow
|
51
|
+
puts '-'*80, ''
|
52
|
+
|
53
|
+
git tag: "settings-files"
|
54
|
+
git log: "--reverse --oneline HEAD...dsl"
|
55
|
+
|
56
|
+
# ----- Start the application ---------------------------------------------------------------------
|
57
|
+
|
58
|
+
unless ENV['RAILS_NO_SERVER_START']
|
59
|
+
require 'net/http'
|
60
|
+
if (begin; Net::HTTP.get(URI('http://localhost:3000')); rescue Errno::ECONNREFUSED; false; rescue Exception; true; end)
|
61
|
+
puts "\n"
|
62
|
+
say_status "ERROR", "Some other application is running on port 3000!\n", :red
|
63
|
+
puts '-'*80
|
64
|
+
|
65
|
+
port = ask("Please provide free port:", :bold)
|
66
|
+
else
|
67
|
+
port = '3000'
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "", "="*80
|
71
|
+
say_status "DONE", "\e[1mStarting the application. Open http://localhost:#{port}\e[0m", :yellow
|
72
|
+
puts "="*80, ""
|
73
|
+
|
74
|
+
run "rails server --port=#{port}"
|
75
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{ "number_of_shards": 1, "number_of_replicas": 0 }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -291,7 +291,9 @@ files:
|
|
291
291
|
- lib/rails/templates/02-pretty.rb
|
292
292
|
- lib/rails/templates/03-expert.rb
|
293
293
|
- lib/rails/templates/04-dsl.rb
|
294
|
+
- lib/rails/templates/05-settings-files.rb
|
294
295
|
- lib/rails/templates/articles.yml.gz
|
296
|
+
- lib/rails/templates/articles_settings.json
|
295
297
|
- lib/rails/templates/index.html.dsl.erb
|
296
298
|
- lib/rails/templates/index.html.erb
|
297
299
|
- lib/rails/templates/indexer.rb
|