stretcher 1.18.1 → 1.19.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.
- checksums.yaml +4 -4
- data/README.md +16 -2
- data/lib/stretcher/index.rb +18 -0
- data/lib/stretcher/index_type.rb +4 -0
- data/lib/stretcher/version.rb +1 -1
- data/spec/lib/stretcher_index_spec.rb +19 -0
- data/spec/lib/stretcher_index_type_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35a3ec878b9724b7e1bb69573a589796e8fc2cfa
|
4
|
+
data.tar.gz: 156e3e208e02a9d0e5b16412d1608c281f46d38b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3b1d5e27fb23612c24f9da8cd48e515f70ce112b9e02c50b7ce4e64fb30865f3084701d53a8d96e99b01fd92771e19bb362ed7f53b9607f014cdfd4570dfe0f
|
7
|
+
data.tar.gz: 23d81d0f467e589ef5de3f16c94e585d534647b4edf6bd75c6c173fd6f1d6e4dbfbb97afdee90408b1876c02b2e6d3b129eeace66bd2a5985bfe347e60b2eda5
|
data/README.md
CHANGED
@@ -83,6 +83,19 @@ docs = [{"_type" => "tweet", "_id" => 91011, "text" => "Bulked"}]
|
|
83
83
|
server.index(:foo).bulk_index(docs)
|
84
84
|
```
|
85
85
|
|
86
|
+
### Percolate
|
87
|
+
|
88
|
+
Implements the ElasticSearch [Percolate API](http://www.elasticsearch.org/guide/reference/api/percolate/)
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
# Register a new percolate query
|
92
|
+
server.index(:foo).register_percolator_query(query_name, query_hash)
|
93
|
+
# Check a document against an index, returns an array of query matches
|
94
|
+
server.index(:foo).type(:foo1).percolate(doc)
|
95
|
+
# Delete a percolate query
|
96
|
+
server.index(:foo).delete_percolator_query(query_name)
|
97
|
+
```
|
98
|
+
|
86
99
|
### Full Documentation
|
87
100
|
|
88
101
|
This README documents only part of stretcher's API. The full documentation for stretcher is available in its [full rdocs](http://rdoc.info/github/PoseBiz/stretcher/master/frames).
|
@@ -115,8 +128,9 @@ Specs may be run with `rake spec`
|
|
115
128
|
|
116
129
|
## Used By
|
117
130
|
|
118
|
-
[Pose](http://pose.com)
|
119
|
-
[Get Satisfaction](https://getsatisfaction.com/corp/)
|
131
|
+
* [Pose](http://pose.com)
|
132
|
+
* [Get Satisfaction](https://getsatisfaction.com/corp/)
|
133
|
+
|
120
134
|
Email or tweet @andrewvc if you'd like to be added to this list!
|
121
135
|
|
122
136
|
## Contributors
|
data/lib/stretcher/index.rb
CHANGED
@@ -164,10 +164,28 @@ module Stretcher
|
|
164
164
|
request(:post, "_optimize", options)
|
165
165
|
end
|
166
166
|
|
167
|
+
# Registers a percolate query against the index
|
168
|
+
# http://www.elasticsearch.org/guide/reference/api/percolate/
|
169
|
+
def register_percolator_query(query_name, options = {})
|
170
|
+
server.request(:put, percolator_query_path(query_name), nil, options)
|
171
|
+
end
|
172
|
+
|
173
|
+
# Deletes a percolate query from the index
|
174
|
+
# http://www.elasticsearch.org/guide/reference/api/percolate/
|
175
|
+
def delete_percolator_query(query_name)
|
176
|
+
server.request(:delete, percolator_query_path(query_name))
|
177
|
+
end
|
178
|
+
|
167
179
|
# Full path to this index
|
168
180
|
def path_uri(path="/")
|
169
181
|
p = @server.path_uri("/#{name}")
|
170
182
|
path ? p << "/#{path}" : p
|
171
183
|
end
|
184
|
+
|
185
|
+
private
|
186
|
+
|
187
|
+
def percolator_query_path(query_name)
|
188
|
+
server.path_uri("/_percolator/#{name}/#{query_name}")
|
189
|
+
end
|
172
190
|
end
|
173
191
|
end
|
data/lib/stretcher/index_type.rb
CHANGED
data/lib/stretcher/version.rb
CHANGED
@@ -256,4 +256,23 @@ describe Stretcher::Index do
|
|
256
256
|
|
257
257
|
end
|
258
258
|
|
259
|
+
context 'percolator' do
|
260
|
+
let(:request_url) { "http://localhost:9200/_percolator/foo/bar" }
|
261
|
+
|
262
|
+
describe '#register_percolator_query' do
|
263
|
+
it "registers the percolator query with a put request" do
|
264
|
+
expect(index.register_percolator_query('bar', {:query => {:term => {:baz => 'qux'}}}).ok).to be_true
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
describe '#delete_percolator_query' do
|
269
|
+
before do
|
270
|
+
index.register_percolator_query('bar', {:query => {:term => {:baz => 'qux'}}}).ok
|
271
|
+
end
|
272
|
+
|
273
|
+
it "deletes the percolator query with a delete request" do
|
274
|
+
expect(index.delete_percolator_query('bar').ok).to be_true
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
259
278
|
end
|
@@ -179,4 +179,14 @@ describe Stretcher::IndexType do
|
|
179
179
|
type.exists?(987).should be_false
|
180
180
|
end
|
181
181
|
end
|
182
|
+
|
183
|
+
describe 'percolate' do
|
184
|
+
before do
|
185
|
+
index.register_percolator_query('bar', {:query => {:term => {:baz => 'qux'}}}).ok
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'returns matching percolated queries based on the document' do
|
189
|
+
type.percolate({:baz => 'qux'}).matches.should == ['bar']
|
190
|
+
end
|
191
|
+
end
|
182
192
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stretcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Cholakian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|