elastic_searchable 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,6 +19,15 @@ pkg
19
19
  test/*.log
20
20
  test/*.sqlite3
21
21
 
22
+ # For vim:
23
+ *.swp
24
+
25
+ # For MacOS:
26
+ .DS_Store
27
+
28
+ # git files
29
+ *.orig
30
+
22
31
  # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
23
32
  #
24
33
  # * Create a file at ~/.gitignore
@@ -30,10 +39,6 @@ test/*.sqlite3
30
39
  #
31
40
  # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
32
41
  #
33
- # For MacOS:
34
- #
35
- #.DS_Store
36
- #
37
42
  # For TextMate
38
43
  #*.tmproj
39
44
  #tmtags
@@ -42,6 +47,4 @@ test/*.sqlite3
42
47
  #*~
43
48
  #\#*
44
49
  #.\#*
45
- #
46
- # For vim:
47
- #*.swp
50
+
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
+ source "http://rubygems.org"
2
+
1
3
  gemspec
2
4
 
data/Rakefile CHANGED
@@ -9,22 +9,5 @@ Rake::TestTask.new(:test) do |test|
9
9
  test.pattern = 'test/**/test_*.rb'
10
10
  test.verbose = true
11
11
  end
12
-
13
- require 'rcov/rcovtask'
14
- Rcov::RcovTask.new do |test|
15
- test.libs << 'test'
16
- test.pattern = 'test/**/test_*.rb'
17
- test.verbose = true
18
- end
19
-
20
12
  task :default => :test
21
13
 
22
- require 'rake/rdoctask'
23
- Rake::RDocTask.new do |rdoc|
24
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
25
-
26
- rdoc.rdoc_dir = 'rdoc'
27
- rdoc.title = "elastic_searchable #{version}"
28
- rdoc.rdoc_files.include('README*')
29
- rdoc.rdoc_files.include('lib/**/*.rb')
30
- end
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
25
25
  s.add_development_dependency(%q<rcov>, [">= 0"])
26
26
  s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
27
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
27
28
 
28
29
  s.files = `git ls-files`.split("\n")
29
30
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -1,4 +1,4 @@
1
1
  module ElasticSearchable
2
- VERSION = '0.6.6'
2
+ VERSION = '0.6.7'
3
3
  end
4
4
 
@@ -28,7 +28,10 @@ module ElasticSearchable
28
28
  def logger
29
29
  @@logger
30
30
  end
31
- #perform a request to the elasticsearch server
31
+ # perform a request to the elasticsearch server
32
+ # configuration:
33
+ # ElasticSearchable.base_uri 'host:port' controls where to send request to
34
+ # ElasticSearchable.debug_output outputs all http traffic to console
32
35
  def request(method, url, options = {})
33
36
  response = self.send(method, url, options)
34
37
  logger.debug "elasticsearch request: #{method} #{url} #{"took #{response['took']}ms" if response['took']}"
data/test/helper.rb CHANGED
@@ -10,6 +10,7 @@ end
10
10
  require 'test/unit'
11
11
  require 'shoulda'
12
12
  require 'mocha'
13
+ require 'ruby-debug'
13
14
 
14
15
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
16
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -18,9 +18,11 @@ ActiveRecord::Schema.define(:version => 1) do
18
18
  create_table :friends, :force => true do |t|
19
19
  t.column :name, :string
20
20
  t.column :favorite_color, :string
21
+ t.belongs_to :book
21
22
  end
22
23
  create_table :books, :force => true do |t|
23
24
  t.column :title, :string
25
+ t.column :isbn, :string
24
26
  end
25
27
  create_table :max_page_size_classes, :force => true do |t|
26
28
  t.column :name, :string
@@ -7,7 +7,7 @@ class TestElasticSearchable < Test::Unit::TestCase
7
7
  ElasticSearchable.debug_output
8
8
 
9
9
  class Post < ActiveRecord::Base
10
- elastic_searchable
10
+ elastic_searchable :index_options => {'number_of_replicas' => 0, 'number_of_shards' => 1}
11
11
  after_index :indexed
12
12
  after_index_on_create :indexed_on_create
13
13
  def indexed
@@ -76,6 +76,7 @@ class TestElasticSearchable < Test::Unit::TestCase
76
76
 
77
77
  context 'with empty index when multiple database records' do
78
78
  setup do
79
+ Post.delete_all
79
80
  Post.create_index
80
81
  @first_post = Post.create :title => 'foo', :body => "first bar"
81
82
  @second_post = Post.create :title => 'foo', :body => "second bar"
@@ -164,7 +165,7 @@ class TestElasticSearchable < Test::Unit::TestCase
164
165
 
165
166
 
166
167
  class Blog < ActiveRecord::Base
167
- elastic_searchable :if => proc {|b| b.should_index? }
168
+ elastic_searchable :if => proc {|b| b.should_index? }, :index_options => {'number_of_replicas' => 0, 'number_of_shards' => 1}
168
169
  def should_index?
169
170
  false
170
171
  end
@@ -184,8 +185,12 @@ class TestElasticSearchable < Test::Unit::TestCase
184
185
  end
185
186
 
186
187
  class User < ActiveRecord::Base
187
- elastic_searchable :index_options => { "analysis.analyzer.default.tokenizer" => 'standard', "analysis.analyzer.default.filter" => ["standard", "lowercase", 'porterStem'] },
188
- :mapping => {:properties => {:name => {:type => :string, :index => :not_analyzed}}}
188
+ elastic_searchable :index_options => {
189
+ 'number_of_replicas' => 0,
190
+ 'number_of_shards' => 1,
191
+ "analysis.analyzer.default.tokenizer" => 'standard',
192
+ "analysis.analyzer.default.filter" => ["standard", "lowercase", 'porterStem']},
193
+ :mapping => {:properties => {:name => {:type => :string, :index => :not_analyzed}}}
189
194
  end
190
195
  context 'activerecord class with :index_options and :mapping' do
191
196
  context 'creating index' do
@@ -195,8 +200,8 @@ class TestElasticSearchable < Test::Unit::TestCase
195
200
  should 'have used custom index_options' do
196
201
  @status = ElasticSearchable.request :get, '/elastic_searchable/_status'
197
202
  expected = {
198
- "index.number_of_replicas" => "1",
199
- "index.number_of_shards" => "5",
203
+ "index.number_of_replicas" => "0",
204
+ "index.number_of_shards" => "1",
200
205
  "index.analysis.analyzer.default.tokenizer" => "standard",
201
206
  "index.analysis.analyzer.default.filter.0" => "standard",
202
207
  "index.analysis.analyzer.default.filter.1" => "lowercase",
@@ -219,19 +224,27 @@ class TestElasticSearchable < Test::Unit::TestCase
219
224
  end
220
225
 
221
226
  class Friend < ActiveRecord::Base
222
- elastic_searchable :json => {:only => [:name]}
227
+ belongs_to :book
228
+ elastic_searchable :json => {:include => {:book => {:only => :title}}, :only => :name}, :index_options => {'number_of_replicas' => 0, 'number_of_shards' => 1}
223
229
  end
224
- context 'activerecord class with optiona :json config' do
230
+ context 'activerecord class with optional :json config' do
225
231
  context 'creating index' do
226
232
  setup do
227
233
  Friend.create_index
228
- @friend = Friend.create! :name => 'bob', :favorite_color => 'red'
234
+ @book = Book.create! :isbn => '123abc', :title => 'another world'
235
+ @friend = Friend.new :name => 'bob', :favorite_color => 'red'
236
+ @friend.book = @book
237
+ @friend.save!
229
238
  Friend.refresh_index
230
239
  end
231
240
  should 'index json with configuration' do
232
241
  @response = ElasticSearchable.request :get, "/elastic_searchable/friends/#{@friend.id}"
242
+ # should not index:
243
+ # friend.favorite_color
244
+ # book.isbn
233
245
  expected = {
234
- "name" => 'bob' #favorite_color should not be indexed
246
+ "name" => 'bob',
247
+ 'book' => {'title' => 'another world'}
235
248
  }
236
249
  assert_equal expected, @response['_source'], @response.inspect
237
250
  end
@@ -290,7 +303,7 @@ class TestElasticSearchable < Test::Unit::TestCase
290
303
  end
291
304
 
292
305
  class MaxPageSizeClass < ActiveRecord::Base
293
- elastic_searchable
306
+ elastic_searchable :index_options => {'number_of_replicas' => 0, 'number_of_shards' => 1}
294
307
  def self.max_per_page
295
308
  1
296
309
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_searchable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 6
10
- version: 0.6.6
9
+ - 7
10
+ version: 0.6.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Sonnek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-11 00:00:00 Z
18
+ date: 2011-04-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activerecord
@@ -171,6 +171,20 @@ dependencies:
171
171
  version: 1.3.2
172
172
  type: :development
173
173
  version_requirements: *id010
174
+ - !ruby/object:Gem::Dependency
175
+ name: ruby-debug
176
+ prerelease: false
177
+ requirement: &id011 !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ hash: 3
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ type: :development
187
+ version_requirements: *id011
174
188
  description: integrate the elastic search engine with rails
175
189
  email:
176
190
  - ryan@codecrate.com
@@ -187,7 +201,6 @@ files:
187
201
  - LICENSE.txt
188
202
  - README.rdoc
189
203
  - Rakefile
190
- - VERSION
191
204
  - elastic_searchable.gemspec
192
205
  - lib/elastic_searchable.rb
193
206
  - lib/elastic_searchable/active_record_extensions.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.6.1