elastirad 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -3
- data/README.md +9 -2
- data/VERSION +1 -1
- data/lib/elastirad/client.rb +28 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ed4287d61f6fec0d24dd8ec37308843c640aa8d
|
4
|
+
data.tar.gz: 22007d9e84a46dc64798c2b94e405c0715dcef78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebeee0de92838c8c01ab3365ec6075c6888dcd16d8dadbf05d39415c271a783ba3164e3b109f45cd050f0a1e4ec75366c6e2a389557b072a58e2356f03da01e3
|
7
|
+
data.tar.gz: df343aa66cd68ce1e8fb5f6051f2ed228660e8a6de1a13a0cd05ce0463e0212f1d37544dce7b22e5a8f1ef5bdcc0d642259fd63712eab7178b6261c6b3826353
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
|
+
- **2014-03-24**: 0.0.3
|
4
|
+
- Add Elastirad::Client::rad_request_all() method
|
5
|
+
- Expose Elastirad::Client::sIndex as rw accessor
|
6
|
+
|
3
7
|
- **2014-03-15**: 0.0.2
|
4
|
-
- Fix bug in #rad_index
|
5
|
-
- Fix bug for YARD README.md formatting
|
6
8
|
- Add documentation of Elasticsearch::API mixin functionality
|
7
9
|
- Add CHANGELOG.md excerpt to README.md
|
10
|
+
- Fix bug in #rad_index
|
11
|
+
- Fix bug for YARD README.md formatting
|
8
12
|
|
9
13
|
- **2014-03-14**: 0.0.1
|
10
|
-
- Initial release
|
14
|
+
- Initial release
|
15
|
+
- Custom Elasticsearch::API mixin client
|
data/README.md
CHANGED
@@ -55,6 +55,10 @@ Download and install elastirad with the following:
|
|
55
55
|
|
56
56
|
result_hash = rad.rad_request({ :path => ['article', 1 ] })
|
57
57
|
|
58
|
+
# retreive all responses for :get requests only
|
59
|
+
|
60
|
+
result_hash = rad.rad_request_all({ :path => 'article/_search' })
|
61
|
+
|
58
62
|
# optional :verb can be used for non-GET requests, :get is used by default
|
59
63
|
|
60
64
|
article = { :title => 'Hello World', :by => 'John Doe' }
|
@@ -97,11 +101,14 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
|
|
97
101
|
#Change Log
|
98
102
|
-----------
|
99
103
|
|
104
|
+
- **2014-03-24**: 0.0.3
|
105
|
+
- Add Elastirad::Client::rad_request_all() method
|
106
|
+
- Expose Elastirad::Client::sIndex as rw accessor
|
100
107
|
- **2014-03-15**: 0.0.2
|
101
|
-
- Fix bug in #rad_index
|
102
|
-
- Fix bug for YARD README.md formatting
|
103
108
|
- Add documentation of Elasticsearch::API mixin functionality
|
104
109
|
- Add CHANGELOG.md excerpt to README.md
|
110
|
+
- Fix bug in #rad_index
|
111
|
+
- Fix bug for YARD README.md formatting
|
105
112
|
- **2014-03-14**: 0.0.1
|
106
113
|
- Initial release
|
107
114
|
- Custom Elasticsearch::API mixin client
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/elastirad/client.rb
CHANGED
@@ -5,6 +5,7 @@ require 'elasticsearch/api'
|
|
5
5
|
module Elastirad
|
6
6
|
class Client
|
7
7
|
include Elasticsearch::API
|
8
|
+
attr_accessor :sIndex
|
8
9
|
|
9
10
|
def initialize(dOptions={})
|
10
11
|
iPort = iPort.to_i if iPort.is_a?(String)
|
@@ -45,6 +46,33 @@ module Elastirad
|
|
45
46
|
{'Content-Type' => 'application/json'}
|
46
47
|
end
|
47
48
|
|
49
|
+
def rad_request_all(dEsReq={})
|
50
|
+
if dEsReq.has_key?(:body)
|
51
|
+
if dEsReq[:body].is_a?(String)
|
52
|
+
dEsReqBody = dEsReq[:body] \
|
53
|
+
? MultiJson.decode( dEsResBody, :symbolize_keys => true ) : {}
|
54
|
+
dEsReq[:body] = dEsReqBody
|
55
|
+
end
|
56
|
+
else
|
57
|
+
dEsReq[:body] = {}
|
58
|
+
end
|
59
|
+
dEsReq[:body][:from] = 0
|
60
|
+
dEsRes1 = self.rad_request( dEsReq )
|
61
|
+
dEsRes = dEsRes1
|
62
|
+
if !dEsReq.has_key?(:verb) || dEsReq[:verb] == :get || dEsReq[:verb].downcase == 'get'
|
63
|
+
if dEsRes1.has_key?(:hits) && dEsRes1[:hits].has_key?(:total)
|
64
|
+
iHitsTotal = dEsRes1[:hits][:total].to_i
|
65
|
+
iHitsSize = dEsRes1[:hits][:hits].length.to_i
|
66
|
+
if iHitsTotal > iHitsSize
|
67
|
+
dEsReq[:body][:size] = iHitsTotal
|
68
|
+
dEsRes2 = self.rad_request( dEsReq )
|
69
|
+
dEsRes = dEsRes2
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
return dEsRes
|
74
|
+
end
|
75
|
+
|
48
76
|
private
|
49
77
|
|
50
78
|
def makeUrl(sProtocol='http',sHostname='localhost',iPort=9200)
|