Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix creating index with settings + mapping

  • Loading branch information...
commit 8cb1ff991530c0d18abbcbf611d5cdfeaf78d1a6 1 parent c496d2f
Ryan Sonnek authored
View
5 lib/elastic_searchable/index.rb
@@ -20,8 +20,9 @@ def update_index_mapping
# create the index
# http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html
def create_index
- options = self.elastic_options[:index_options] || {}
- options = options.merge(:mappings => {index_type => self.elastic_options[:mapping]}) if self.elastic_options[:mapping]
+ options = {}
+ options.merge! :settings => self.elastic_options[:index_options] if self.elastic_options[:index_options]
+ options.merge! :mappings => {index_type => self.elastic_options[:mapping]} if self.elastic_options[:mapping]
ElasticSearchable.request :put, index_path, :body => options.to_json
end
View
10 test/test_elastic_searchable.rb
@@ -23,7 +23,7 @@ def indexed_on_create?
@indexed_on_create
end
end
- context 'Post class with default elastic_searchable config' do
+ context 'activerecord class with default elastic_searchable config' do
setup do
@clazz = Post
end
@@ -35,7 +35,7 @@ def indexed_on_create?
end
end
- context 'ElasticSearchable.request with invalid url' do
+ context 'Model.request with invalid url' do
should 'raise error' do
assert_raises ElasticSearchable::ElasticError do
ElasticSearchable.request :get, '/elastic_searchable/foobar/notfound'
@@ -43,7 +43,7 @@ def indexed_on_create?
end
end
- context 'Post.create_index' do
+ context 'Model.create_index' do
setup do
Post.create_index
Post.refresh_index
@@ -62,7 +62,7 @@ def indexed_on_create?
end
end
- context 'Post.create' do
+ context 'Model.create' do
setup do
@post = Post.create :title => 'foo', :body => "bar"
end
@@ -85,7 +85,7 @@ def indexed_on_create?
ElasticSearchable.expects(:request).raises(ElasticSearchable::ElasticError.new('faux error'))
Post.reindex
end
- context 'Post.reindex' do
+ context 'Model.reindex' do
setup do
Post.reindex :per_page => 1, :scope => Post.scoped(:order => 'body desc')
Post.refresh_index
Please sign in to comment.
Something went wrong with that request. Please try again.