Module: Elastico::Client

Defined in:
lib/elastico/client.rb

Instance Method Summary collapse

Instance Method Details

#delete_instance(url) ⇒ Object



10
11
12
# File 'lib/elastico/client.rb', line 10

def delete_instance url
	RestClient.delete url
end

#elastico_search(hash_respond_wanted = true) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/elastico/client.rb', line 21

def elastico_search(hash_respond_wanted = true)
	to_url = self.elastico_url + self.elastico_index_name + "/_search" 
	
	RestClient.post(to_url, self.search_query, :content_type => :json, :accept => :json) do |response, request, result|
	  ret = JSON.pretty_generate(JSON.parse(response.to_str))
			hash_respond_wanted ? JSON.parse(ret) : ret
	end

end

#general_request(content = nil, url = self.elastico_url, options = { :hash_respond_wanted => :true }) ⇒ Object



14
15
16
17
18
19
# File 'lib/elastico/client.rb', line 14

def general_request(content=nil, url=self.elastico_url, options = { :hash_respond_wanted => :true })
		RestClient.post(url, content, :content_type => :json, :accept => :json) do |response, request, result|
		  ret = JSON.pretty_generate(JSON.parse(response.to_str))
				options[:hash_respond_wanted] ? JSON.parse(ret) : ret
		end
end

#send_settings_mappings_to_elasticsearch_serverObject



3
4
5
6
7
8
# File 'lib/elastico/client.rb', line 3

def send_settings_mappings_to_elasticsearch_server
	to_url = self.elastico_url + self.elastico_index_name
	RestClient.put(to_url, self.settings_and_mappings_json, :content_type => :json, :accept => :json) do |response, request, result|
	  puts JSON.pretty_generate(JSON.parse(response.to_str))
	end
end