elastico 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -6
- data/lib/elastico/client.rb +1 -4
- data/lib/elastico/index.rb +0 -5
- data/lib/elastico/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -27,6 +27,9 @@ Install elasticsearch:
|
|
27
27
|
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.5.tar.gz .
|
28
28
|
tar -zxvf elasticsearch-0.90.5.tar.gz /bin/
|
29
29
|
rm elasticsearch-0.90.5.tar.gz
|
30
|
+
|
31
|
+
Now run it:
|
32
|
+
|
30
33
|
/bin/elasticsearch-0.90.5/bin/elasticsearch -f
|
31
34
|
|
32
35
|
Add this line to your application's Gemfile:
|
@@ -50,12 +53,14 @@ In your model:
|
|
50
53
|
attr_accessible :color, :name
|
51
54
|
|
52
55
|
def self.prepare_elastico_settings_and_mappings_json
|
53
|
-
json = { "apple" =>
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
json = { "apple" =>
|
57
|
+
{
|
58
|
+
"properties" =>
|
59
|
+
{
|
60
|
+
"name" => {"type" => "string"},
|
61
|
+
"color" => {"type" => "string"}
|
62
|
+
}
|
63
|
+
}}.to_json
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
@@ -83,6 +88,9 @@ In your controller:
|
|
83
88
|
# now do something with your apples
|
84
89
|
end
|
85
90
|
|
91
|
+
Import your active record instances simply by:
|
92
|
+
|
93
|
+
Apple.elastico_import_all
|
86
94
|
|
87
95
|
Learn by Example
|
88
96
|
================
|
data/lib/elastico/client.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Elastico
|
2
2
|
module Client
|
3
3
|
def send_settings_mappings_to_elasticsearch_server
|
4
|
-
to_url = self.elastico_url + self.elastico_index_name
|
4
|
+
to_url = self.elastico_url + self.elastico_index_name
|
5
5
|
puts to_url
|
6
6
|
RestClient.put(to_url, self.settings_and_mappings_json, :content_type => :json, :accept => :json) do |response, request, result|
|
7
7
|
puts JSON.pretty_generate(JSON.parse(response.to_str))
|
@@ -30,6 +30,3 @@ module Elastico
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
# curl -XGET "http://localhost:9200/apples_development/_search" -d '{"query":{"term":{"color":"test"}}}'
|
34
|
-
|
35
|
-
# RestClient.post "http://localhost:9200/apples_development/_search", '{"query":{"term":{"color":"test"}}}', :content_type => :json
|
data/lib/elastico/index.rb
CHANGED
data/lib/elastico/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|