eson-http 0.7.0
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/LICENSE.md +20 -0
- data/README.md +111 -0
- data/Rakefile +31 -0
- data/bin/elshell +20 -0
- data/eson-http.gemspec +28 -0
- data/lib/eson-http.rb +55 -0
- data/lib/eson/http.rb +16 -0
- data/lib/eson/http/api.rb +13 -0
- data/lib/eson/http/client.rb +24 -0
- data/lib/eson/http/cluster/health.rb +15 -0
- data/lib/eson/http/cluster/nodes.rb +14 -0
- data/lib/eson/http/cluster/shutdown.rb +15 -0
- data/lib/eson/http/cluster/state.rb +16 -0
- data/lib/eson/http/cluster/stats.rb +18 -0
- data/lib/eson/http/core/bulk.rb +33 -0
- data/lib/eson/http/core/count.rb +26 -0
- data/lib/eson/http/core/delete.rb +14 -0
- data/lib/eson/http/core/delete_by_query.rb +22 -0
- data/lib/eson/http/core/get.rb +15 -0
- data/lib/eson/http/core/index.rb +26 -0
- data/lib/eson/http/core/mget.rb +23 -0
- data/lib/eson/http/core/more_like_this.rb +14 -0
- data/lib/eson/http/core/msearch.rb +47 -0
- data/lib/eson/http/core/percolate.rb +16 -0
- data/lib/eson/http/core/search.rb +29 -0
- data/lib/eson/http/core/simple_search.rb +18 -0
- data/lib/eson/http/indices/aliases.rb +14 -0
- data/lib/eson/http/indices/analyze.rb +14 -0
- data/lib/eson/http/indices/clear_cache.rb +18 -0
- data/lib/eson/http/indices/close_index.rb +14 -0
- data/lib/eson/http/indices/create_index.rb +14 -0
- data/lib/eson/http/indices/delete_index.rb +14 -0
- data/lib/eson/http/indices/delete_mapping.rb +17 -0
- data/lib/eson/http/indices/delete_template.rb +14 -0
- data/lib/eson/http/indices/exists.rb +14 -0
- data/lib/eson/http/indices/flush.rb +18 -0
- data/lib/eson/http/indices/get_mapping.rb +20 -0
- data/lib/eson/http/indices/get_settings.rb +18 -0
- data/lib/eson/http/indices/get_template.rb +14 -0
- data/lib/eson/http/indices/open_index.rb +14 -0
- data/lib/eson/http/indices/optimize.rb +18 -0
- data/lib/eson/http/indices/put_mapping.rb +16 -0
- data/lib/eson/http/indices/put_template.rb +14 -0
- data/lib/eson/http/indices/refresh.rb +18 -0
- data/lib/eson/http/indices/segments.rb +18 -0
- data/lib/eson/http/indices/snapshot.rb +18 -0
- data/lib/eson/http/indices/stats.rb +18 -0
- data/lib/eson/http/indices/status.rb +18 -0
- data/lib/eson/http/indices/update_settings.rb +18 -0
- data/lib/eson/http/request.rb +95 -0
- data/lib/eson/modules/response_parser.rb +22 -0
- data/lib/eson/modules/status_handler.rb +24 -0
- data/log4j.properties +18 -0
- data/test/http/client_test.rb +14 -0
- data/test/http/cluster_test.rb +58 -0
- data/test/http/index_test.rb +180 -0
- data/test/http/indices/basics_test.rb +257 -0
- data/test/http/query_test.rb +70 -0
- data/test/modules/query_plugin_test.rb +40 -0
- data/test/seeds/seeds.rb +30 -0
- data/test/test_config.rb +33 -0
- metadata +202 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
module Eson
|
2
|
+
module HTTP
|
3
|
+
module Count
|
4
|
+
include Shared::Search
|
5
|
+
extend API
|
6
|
+
|
7
|
+
request_method :post
|
8
|
+
|
9
|
+
def bare_path
|
10
|
+
unless types.empty?
|
11
|
+
path = "{-list|,|indices}/{-list|,|types}/"
|
12
|
+
else
|
13
|
+
path = "{-list|,|indices}/"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def path
|
18
|
+
path = bare_path + "_count"
|
19
|
+
end
|
20
|
+
|
21
|
+
def source
|
22
|
+
MultiJson.encode(query)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Eson
|
2
|
+
module HTTP
|
3
|
+
module DeleteByQuery
|
4
|
+
extend API
|
5
|
+
include Shared::DeleteByQuery
|
6
|
+
|
7
|
+
request_method :delete
|
8
|
+
|
9
|
+
def bare_path
|
10
|
+
unless types.empty?
|
11
|
+
path = "{-list|,|indices}/{-list|,|types}/"
|
12
|
+
else
|
13
|
+
path = "{-list|,|indices}/"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def path
|
18
|
+
bare_path + "_query"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Eson
|
2
|
+
module HTTP
|
3
|
+
module Index
|
4
|
+
include Shared::Index
|
5
|
+
extend API
|
6
|
+
|
7
|
+
request_method :put
|
8
|
+
|
9
|
+
def path
|
10
|
+
if id
|
11
|
+
"/{index}/{type}/{id}"
|
12
|
+
else
|
13
|
+
"/{index}/{type}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def request_method
|
18
|
+
if id
|
19
|
+
:put
|
20
|
+
else
|
21
|
+
:post
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Eson
|
2
|
+
module HTTP
|
3
|
+
module MultiGet
|
4
|
+
include Shared::MultiGet
|
5
|
+
extend API
|
6
|
+
|
7
|
+
request_method :get
|
8
|
+
|
9
|
+
def bare_path
|
10
|
+
unless type
|
11
|
+
path = "{index}/{type}/"
|
12
|
+
else
|
13
|
+
path = "{index}/"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def path
|
18
|
+
path = bare_path + "_mget"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Eson
|
2
|
+
module HTTP
|
3
|
+
module MultiSearch
|
4
|
+
include Shared::MultiSearch
|
5
|
+
extend API
|
6
|
+
|
7
|
+
request_method :post
|
8
|
+
|
9
|
+
def path
|
10
|
+
'/_msearch'
|
11
|
+
end
|
12
|
+
|
13
|
+
def source
|
14
|
+
msearch.map {|r| serialize_request(r)}.join
|
15
|
+
end
|
16
|
+
|
17
|
+
def serialize_request(request)
|
18
|
+
case request
|
19
|
+
when Eson::HTTP::Search
|
20
|
+
MultiJson.encode(to_params_hash(request)) << "\n" << request.source << "\n"
|
21
|
+
else
|
22
|
+
warn("Unserializable request #{request.inspect}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_params_hash(r)
|
27
|
+
r.url_params.inject({}) do |h, p|
|
28
|
+
val = r.send(p)
|
29
|
+
if val
|
30
|
+
h[p] = val unless val.respond_to?(:empty?) && val.empty?
|
31
|
+
end
|
32
|
+
h
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def path
|
37
|
+
unless types.empty?
|
38
|
+
path = "{-list|,|indices}/{-list|,|types}/"
|
39
|
+
else
|
40
|
+
path = "{-list|,|indices}/"
|
41
|
+
end
|
42
|
+
|
43
|
+
path << "_msearch"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Eson
|
2
|
+
module HTTP
|
3
|
+
module Search
|
4
|
+
include Shared::Search
|
5
|
+
extend API
|
6
|
+
|
7
|
+
request_method :post
|
8
|
+
|
9
|
+
def bare_path
|
10
|
+
unless types.empty?
|
11
|
+
path = "{-list|,|indices}/{-list|,|types}/"
|
12
|
+
else
|
13
|
+
path = "{-list|,|indices}/"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def path
|
18
|
+
path = bare_path + "_search"
|
19
|
+
|
20
|
+
if scroll
|
21
|
+
path << "/scroll"
|
22
|
+
end
|
23
|
+
|
24
|
+
path
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Eson
|
2
|
+
module HTTP
|
3
|
+
module SimpleSearch
|
4
|
+
include Shared::SimpleSearch
|
5
|
+
extend API
|
6
|
+
|
7
|
+
request_method :get
|
8
|
+
|
9
|
+
def path
|
10
|
+
unless types.empty?
|
11
|
+
"{-list|,|indices}/{-list|,|types}/_search"
|
12
|
+
else
|
13
|
+
"{-list|,|indices}/_search"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Eson
|
2
|
+
module HTTP
|
3
|
+
module GetMapping
|
4
|
+
include Shared::GetMapping
|
5
|
+
extend API
|
6
|
+
|
7
|
+
request_method :get
|
8
|
+
|
9
|
+
def path
|
10
|
+
if !types.empty? && !indices.empty?
|
11
|
+
"/{-list|,|indices}/{-list|,|types}/_mapping"
|
12
|
+
elsif !indices.empty?
|
13
|
+
"/{-list|,|indices}/_mapping"
|
14
|
+
else
|
15
|
+
"/_mapping"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|