redisearch-rb 0.1.7 → 0.1.8
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/lib/redisearch.rb +10 -0
- data/lib/redisearch/version.rb +1 -1
- data/test/redisearch_test.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '01498d9fe5aeb06096b245b7045bc558d66edfb7'
|
4
|
+
data.tar.gz: 659c1c312134ec3acba593feaa8ab1597d21611f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a672c99130602f2461208d94f50e659d77f4e9b38b9b2149ed5e28665b1a5a3283fe6217a4322cdfba4af990849f09bd51fa2b9791f889bdea570458c3d86205
|
7
|
+
data.tar.gz: a283066a539ead576d84dd83265f911d090fbc86b340a1f9b26d033305c5943fece67a7fbd51374c59c2ae86984752341ae39a2d551dee7fbbb29d814ceb1baa
|
data/lib/redisearch.rb
CHANGED
@@ -99,6 +99,12 @@ class RediSearch
|
|
99
99
|
results_to_hash(call(ft_search(query, opts)), opts)
|
100
100
|
end
|
101
101
|
|
102
|
+
# Fetch a document by id
|
103
|
+
def get_by_id(id)
|
104
|
+
Hash[with_reconnect { @redis.hgetall(id) } || []]
|
105
|
+
.tap { |doc| doc['id'] = id unless doc.empty? }
|
106
|
+
end
|
107
|
+
|
102
108
|
# Return information and statistics on the index.
|
103
109
|
# @return [Hash] info returned by Redis key-value pairs
|
104
110
|
#
|
@@ -108,6 +114,10 @@ class RediSearch
|
|
108
114
|
|
109
115
|
private
|
110
116
|
|
117
|
+
def with_reconnect
|
118
|
+
@redis.with_reconnect { yield }
|
119
|
+
end
|
120
|
+
|
111
121
|
def multi
|
112
122
|
@redis.with_reconnect { @redis.multi { yield } }
|
113
123
|
end
|
data/lib/redisearch/version.rb
CHANGED
data/test/redisearch_test.rb
CHANGED
@@ -72,6 +72,16 @@ class RediSearchTest < Minitest::Test
|
|
72
72
|
assert_includes(search_result.to_s, 'Ex Machina')
|
73
73
|
end
|
74
74
|
|
75
|
+
def test_get_by_id
|
76
|
+
assert(@redisearch_client.create_index(@schema))
|
77
|
+
docs = [['id_1', ['title', 'Lost in translation', 'director', 'Sofia Coppola', 'year', '2004']],
|
78
|
+
['id_2', ['title', 'Ex Machina', 'director', 'Alex Garland', 'year', '2014']]]
|
79
|
+
assert(@redisearch_client.add_docs(docs))
|
80
|
+
doc = @redisearch_client.get_by_id('id_1')
|
81
|
+
assert_equal('id_1', doc['id'])
|
82
|
+
assert_equal('Lost in translation', doc['title'])
|
83
|
+
end
|
84
|
+
|
75
85
|
def test_search_simple_query
|
76
86
|
assert(@redisearch_client.create_index(@schema))
|
77
87
|
docs = [['id_1', ['title', 'Lost in translation', 'director', 'Sofia Coppola', 'year', '2004']],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redisearch-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
A simple Ruby client library for RediSearch.
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.6.
|
56
|
+
rubygems_version: 2.6.11
|
57
57
|
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: A simple Ruby client library for RediSearch
|