stretcher 1.7.3 → 1.8.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/lib/stretcher/index_type.rb
CHANGED
@@ -14,8 +14,12 @@ module Stretcher
|
|
14
14
|
# Retrieves the document by ID
|
15
15
|
# Normally this returns the contents of _source, however, the 'raw' flag is passed in, it will return the full response hash
|
16
16
|
# Returns nil if the document does not exist
|
17
|
-
def get(id, raw=false)
|
18
|
-
|
17
|
+
def get(id, options={}, raw=false)
|
18
|
+
if options == true || options == false # Support raw as second argument, legacy API
|
19
|
+
raw = true
|
20
|
+
options = {}
|
21
|
+
end
|
22
|
+
res = request(:get, id, options)
|
19
23
|
raw ? res : res["_source"]
|
20
24
|
end
|
21
25
|
|
data/lib/stretcher/version.rb
CHANGED
@@ -55,7 +55,7 @@ describe Stretcher::IndexType do
|
|
55
55
|
|
56
56
|
describe "put/get/delete/explain" do
|
57
57
|
before do
|
58
|
-
@doc = {:message => "hello!"}
|
58
|
+
@doc = {:message => "hello!", :_timestamp => 1366420401}
|
59
59
|
@put_res = type.put(987, @doc)
|
60
60
|
end
|
61
61
|
|
@@ -77,7 +77,19 @@ describe Stretcher::IndexType do
|
|
77
77
|
}.should raise_exception(Stretcher::RequestError::NotFound)
|
78
78
|
end
|
79
79
|
|
80
|
+
it "should get individual, passing through additional options" do
|
81
|
+
res = type.get(987, {:fields => ['_timestamp']})
|
82
|
+
res._timestamp.should == @doc[:_timestamp]
|
83
|
+
res.message == nil
|
84
|
+
end
|
85
|
+
|
80
86
|
it "should get individual raw documents correctly" do
|
87
|
+
res = type.get(987, {}, true)
|
88
|
+
res["_id"].should == "987"
|
89
|
+
res["_source"].message.should == @doc[:message]
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should get individual raw documents correctly with legacy API" do
|
81
93
|
res = type.get(987, true)
|
82
94
|
res["_id"].should == "987"
|
83
95
|
res["_source"].message.should == @doc[:message]
|
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.8.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-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|