elastic_searchable 0.7.2 → 0.7.3
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.
data/lib/elastic_searchable.rb
CHANGED
@@ -33,7 +33,7 @@ module ElasticSearchable
|
|
33
33
|
# ElasticSearchable.debug_output outputs all http traffic to console
|
34
34
|
def request(method, url, options = {})
|
35
35
|
options.merge! :headers => {'Content-Type' => 'application/json'}
|
36
|
-
options.merge! :body => ElasticSearchable.encode_json(options[:
|
36
|
+
options.merge! :body => ElasticSearchable.encode_json(options[:json_body]) if options[:json_body]
|
37
37
|
|
38
38
|
response = self.send(method, url, options)
|
39
39
|
logger.debug "elasticsearch request: #{method} #{url} #{"took #{response['took']}ms" if response['took']}"
|
@@ -13,7 +13,7 @@ module ElasticSearchable
|
|
13
13
|
# http://www.elasticsearch.com/docs/elasticsearch/rest_api/admin/indices/put_mapping/
|
14
14
|
def update_index_mapping
|
15
15
|
if mapping = self.elastic_options[:mapping]
|
16
|
-
ElasticSearchable.request :put, index_type_path('_mapping'), :
|
16
|
+
ElasticSearchable.request :put, index_type_path('_mapping'), :json_body => {index_type => mapping}
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -23,7 +23,7 @@ module ElasticSearchable
|
|
23
23
|
options = {}
|
24
24
|
options.merge! :settings => self.elastic_options[:index_options] if self.elastic_options[:index_options]
|
25
25
|
options.merge! :mappings => {index_type => self.elastic_options[:mapping]} if self.elastic_options[:mapping]
|
26
|
-
ElasticSearchable.request :put, index_path, :
|
26
|
+
ElasticSearchable.request :put, index_path, :json_body => options
|
27
27
|
end
|
28
28
|
|
29
29
|
# explicitly refresh the index, making all operations performed since the last refresh
|
@@ -112,7 +112,7 @@ module ElasticSearchable
|
|
112
112
|
def reindex(lifecycle = nil)
|
113
113
|
query = {}
|
114
114
|
query.merge! :percolate => "*" if self.class.elastic_options[:percolate]
|
115
|
-
response = ElasticSearchable.request :put, self.class.index_type_path(self.id), :query => query, :
|
115
|
+
response = ElasticSearchable.request :put, self.class.index_type_path(self.id), :query => query, :json_body => self.as_json_for_index
|
116
116
|
|
117
117
|
self.run_callbacks("after_index_on_#{lifecycle}".to_sym) if lifecycle
|
118
118
|
self.run_callbacks(:after_index)
|
@@ -135,7 +135,7 @@ module ElasticSearchable
|
|
135
135
|
# can be done automatically when indexing using :percolate => true config option
|
136
136
|
# http://www.elasticsearch.org/blog/2011/02/08/percolator.html
|
137
137
|
def percolate
|
138
|
-
response = ElasticSearchable.request :get, self.class.index_type_path('_percolate'), :
|
138
|
+
response = ElasticSearchable.request :get, self.class.index_type_path('_percolate'), :json_body => {:doc => self.as_json_for_index}
|
139
139
|
response['matches']
|
140
140
|
end
|
141
141
|
|
@@ -33,7 +33,7 @@ module ElasticSearchable
|
|
33
33
|
query[:sort] = sort
|
34
34
|
end
|
35
35
|
|
36
|
-
response = ElasticSearchable.request :get, index_type_path('_search'), :query => query, :
|
36
|
+
response = ElasticSearchable.request :get, index_type_path('_search'), :query => query, :json_body => options
|
37
37
|
hits = response['hits']
|
38
38
|
ids = hits['hits'].collect {|h| h['_id'].to_i }
|
39
39
|
results = self.find(ids).sort_by {|result| ids.index(result.id) }
|
@@ -362,7 +362,7 @@ class TestElasticSearchable < Test::Unit::TestCase
|
|
362
362
|
end
|
363
363
|
context "when index has configured percolation" do
|
364
364
|
setup do
|
365
|
-
ElasticSearchable.request :put, '/_percolator/elastic_searchable/myfilter', :
|
365
|
+
ElasticSearchable.request :put, '/_percolator/elastic_searchable/myfilter', :json_body => {:query => {:query_string => {:query => 'foo' }}}
|
366
366
|
ElasticSearchable.request :post, '/_percolator/_refresh'
|
367
367
|
end
|
368
368
|
context 'creating an object that matches the percolation' do
|
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 3
|
10
|
+
version: 0.7.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Sonnek
|