stretcher 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/stretcher/index.rb
CHANGED
@@ -48,11 +48,16 @@ module Stretcher
|
|
48
48
|
@server.request :delete, path_uri
|
49
49
|
end
|
50
50
|
|
51
|
-
# Retrieves stats
|
51
|
+
# Retrieves stats for this index
|
52
52
|
def stats
|
53
53
|
@server.request :get, path_uri("/_stats")
|
54
54
|
end
|
55
55
|
|
56
|
+
# Retrieves status for this index
|
57
|
+
def status
|
58
|
+
@server.request :get, path_uri("/_status")
|
59
|
+
end
|
60
|
+
|
56
61
|
# Retrieve the mapping for this index
|
57
62
|
def get_mapping
|
58
63
|
@server.request :get, path_uri("/_mapping")
|
data/lib/stretcher/index_type.rb
CHANGED
@@ -70,6 +70,11 @@ module Stretcher
|
|
70
70
|
server.http.head(path_uri("/#{id}")).status != 404
|
71
71
|
end
|
72
72
|
|
73
|
+
# Issues an Index#search scoped to this type
|
74
|
+
def search(query_opts={}, body=nil)
|
75
|
+
@index.search(query_opts.merge(type: name), body)
|
76
|
+
end
|
77
|
+
|
73
78
|
# Full path to this index type
|
74
79
|
def path_uri(path="/")
|
75
80
|
index.path_uri("/#{name}") + path.to_s
|
data/lib/stretcher/server.rb
CHANGED
@@ -58,6 +58,16 @@ module Stretcher
|
|
58
58
|
req.body = data
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
# Retrieves stats for this server
|
63
|
+
def stats
|
64
|
+
request :get, path_uri("/_stats")
|
65
|
+
end
|
66
|
+
|
67
|
+
# Retrieves status for this server
|
68
|
+
def status
|
69
|
+
request :get, path_uri("/_status")
|
70
|
+
end
|
61
71
|
|
62
72
|
# Returns true if the server is currently reachable, raises an error otherwise
|
63
73
|
def up?
|
data/lib/stretcher/version.rb
CHANGED
@@ -42,6 +42,10 @@ describe Stretcher::Index do
|
|
42
42
|
index.stats['_all'].should_not be_nil
|
43
43
|
end
|
44
44
|
|
45
|
+
it "should return the status without error" do
|
46
|
+
index.status['ok'].should be_true
|
47
|
+
end
|
48
|
+
|
45
49
|
it "should put mappings for new types correctly" do
|
46
50
|
create_tweet_mapping
|
47
51
|
end
|
@@ -57,6 +61,14 @@ describe Stretcher::Index do
|
|
57
61
|
}
|
58
62
|
end
|
59
63
|
|
64
|
+
it "should search without error" do
|
65
|
+
seed_corpus
|
66
|
+
match_text = corpus.first[:text]
|
67
|
+
sleep 1 # ES needs time to update!
|
68
|
+
res = index.search({}, {query: {match: {text: match_text}}})
|
69
|
+
res.results.first.text.should == match_text
|
70
|
+
end
|
71
|
+
|
60
72
|
# TODO: Actually use two indexes
|
61
73
|
it "should msearch across the index returning all docs" do
|
62
74
|
seed_corpus
|
@@ -14,6 +14,20 @@ describe Stretcher::Index do
|
|
14
14
|
type.get_mapping.should == mapping
|
15
15
|
end
|
16
16
|
|
17
|
+
describe "searching" do
|
18
|
+
before do
|
19
|
+
@doc = {message: "hello"}
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should search and find the right doc" do
|
23
|
+
match_text = 'hello'
|
24
|
+
type.put(123123, @doc)
|
25
|
+
sleep 1
|
26
|
+
res = type.search({}, {query: {match: {message: match_text}}})
|
27
|
+
res.results.first.message.should == @doc[:message]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
17
31
|
describe "put/get" do
|
18
32
|
before do
|
19
33
|
@doc = {message: "hello!"}
|
@@ -20,6 +20,14 @@ describe Stretcher::Server do
|
|
20
20
|
it "should properly return that our server is up" do
|
21
21
|
server.up?.should be_true
|
22
22
|
end
|
23
|
+
|
24
|
+
it "should check the stats w/o error" do
|
25
|
+
server.stats
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should check the status w/o error" do
|
29
|
+
server.status.ok.should be_true
|
30
|
+
end
|
23
31
|
|
24
32
|
it "should beget an index object cleanly" do
|
25
33
|
server.index('foo').class.should == Stretcher::Index
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stretcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
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-
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|