Permalink
Browse files

rename elasticsearch_hit to hit

  • Loading branch information...
1 parent defba41 commit 9b2a4da49eb1f67c0690e3d79d4cfda1c6970578 @f1sherman f1sherman committed Jan 28, 2012
@@ -1,6 +1,5 @@
require 'active_record'
require 'backgrounded'
-require 'elastic_searchable/result'
require 'elastic_searchable/queries'
require 'elastic_searchable/callbacks'
require 'elastic_searchable/index'
@@ -33,7 +32,6 @@ def elastic_searchable(options = {})
extend ElasticSearchable::Indexing::ClassMethods
extend ElasticSearchable::Queries
- include ElasticSearchable::Result::InstanceMethods
include ElasticSearchable::Indexing::InstanceMethods
include ElasticSearchable::Callbacks::InstanceMethods
@@ -42,7 +40,7 @@ class << self
backgrounded :delete_id_from_index => ElasticSearchable::Callbacks.backgrounded_options
end
- attr_reader :elasticsearch_hit # the hit json for this result
+ attr_reader :hit # the hit json for this result
attr_accessor :index_lifecycle, :percolations
define_model_callbacks :index, :percolate, :only => :after
after_commit :update_index_on_create_backgrounded, :if => :should_index?, :on => :create
@@ -41,7 +41,7 @@ def search(query, options = {})
results = self.find(ids).sort_by {|result| ids.index(result.id) }
results.each do |result|
- result.instance_variable_set '@elasticsearch_hit', hits['hits'][ids.index(result.id)]
+ result.instance_variable_set '@hit', hits['hits'][ids.index(result.id)]
end
ElasticSearchable::Paginator.handler.new(results, page, options[:size], hits['total'])
@@ -193,17 +193,17 @@ def indexed_on_update?
assert_nil @results.previous_page
assert_nil @results.next_page
end
- should 'have populated elasticsearch_hit' do
- assert_equal @results.first.elasticsearch_hit['_id'], @first_post.id.to_s
+ should 'have populated hit' do
+ assert_equal @results.first.hit['_id'], @first_post.id.to_s
end
end
context 'searching on a term that returns multiple results' do
setup do
@results = Post.search 'foo'
end
- should 'have populated elasticsearch_hit on each record with the correct hit json' do
- assert_equal @results.first.elasticsearch_hit['_id'], @first_post.id.to_s
- assert_equal @results.last.elasticsearch_hit['_id'], @second_post.id.to_s
+ should 'have populated hit on each record with the correct hit json' do
+ assert_equal @results.first.hit['_id'], @first_post.id.to_s
+ assert_equal @results.last.hit['_id'], @second_post.id.to_s
end
end

0 comments on commit 9b2a4da

Please sign in to comment.