redisearch-rb 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9df8fe8e4d7c7a3624eee798a3a495296e244a1c
4
- data.tar.gz: 704632f558f90028067c76ca1ee994ea6d08d70e
2
+ SHA256:
3
+ metadata.gz: 99d803efbd160ce83d3cf58a50b2e739540f143666dc87f18b04c3ff10766577
4
+ data.tar.gz: d83a8a81049e5b6266130f351d2c82381b12abaf93c1f616e7d602b2503d5abb
5
5
  SHA512:
6
- metadata.gz: a9cb8486726435e3832f6b598e9cd8a3addde0623c5371db1d5bca9641d67d0189d2ca4c180aaf3ff53c2c63450930b00536b520668fcbb31e2ab7e7994f6275
7
- data.tar.gz: 6a4d206b73dd350c6a240b805cbf82dcde7ca536492815b2ff6719a5b617ee73ed191e625bdadbfa68ac1cc3cd09e617c47a9a7c2889db3bc77c2c3fac074d34
6
+ metadata.gz: abf6a993f32a3c93979763b3cf22e72a959fffd3d14c8ccf2fa44031b5f1c65a30ddad8715c1226ff7467f2b3ad4146be3edc806248073ec5e6926f75fc233fe
7
+ data.tar.gz: 524ed525611003f0ef515d2eee40ab4a4fcdef851083fa75b053011c1219187f1c2d1ff22c7d3fb6e456b7c53e6a0af42d12f9f6b32701bd91f0ea9a4d8be568
data/Gemfile CHANGED
@@ -1,9 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby '2.4.1'
3
+ ruby '>=2.4.1'
4
4
 
5
5
  gem 'redis', '~> 4.0.1'
6
-
7
6
  group :development, :test do
8
7
  gem 'dotenv'
9
8
  gem 'rake'
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- [![Gem Version](https://badge.fury.io/rb/redisearch-rb.svg)](https://badge.fury.io/rb/redisearch-rb) ![travis-ci](https://travis-ci.org/vruizext/redisearch-rb.svg?branch=master)
1
+ [![Gem Version](https://badge.fury.io/rb/redisearch-rb.svg)](https://badge.fury.io/rb/redisearch-rb)
2
+ [![travis-ci](https://travis-ci.org/vruizext/redisearch-rb.svg?branch=master)](https://travis-ci.org/vruizext/redisearch-rb)
2
3
 
3
4
  # redisearch-rb
4
5
 
@@ -18,7 +18,7 @@ class RediSearch
18
18
  create: [:nooffsets, :nofreqs, :nohl, :nofields],
19
19
  del: [:dd],
20
20
  drop: [:keepdocs],
21
- search: [:nocontent, :verbatim, :nostopwords, :withscores, :withsortkeys],
21
+ search: [:nocontent, :verbatim, :nostopwords, :withscores, :withsortkeys, :highlight, :summarize],
22
22
  sugadd: [:incr],
23
23
  sugget: [:fuzzy, :withscores],
24
24
  }
@@ -1,3 +1,3 @@
1
1
  class RediSearch
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -189,6 +189,40 @@ class RediSearchTest < Minitest::Test
189
189
  assert_equal 'id_2', matches[0]['id']
190
190
  end
191
191
 
192
+ def test_search_summarize
193
+ assert(@redisearch_client.create_index(@schema))
194
+ long_director = 'Steven ' * 80 + 'Sofia Coppola' + ' ' + 'Steven ' * 80
195
+ docs = [['id_1', ['title', 'Lost in translation', 'director', long_director, 'year', '2004']],
196
+ ['id_2', ['title', 'Ex Machina', 'director', 'Alex Garland', 'year', '2014']],
197
+ ['id_3', ['title', 'Terminator', 'director', 'James Cameron', 'year', '1984']],
198
+ ['id_4', ['title', 'Blade Runner', 'director', 'Ridley Scott', 'year', '1982']]]
199
+ assert(@redisearch_client.add_docs(docs))
200
+ matches = @redisearch_client.search('Sofia', summarize: false)
201
+ assert_equal 1, matches.count
202
+ assert_equal long_director.size, matches[0]['director'].size
203
+
204
+ matches = @redisearch_client.search('Sofia', summarize: true)
205
+ assert_equal 1, matches.count
206
+ assert_in_epsilon 122, matches[0]['director'].size, 20
207
+ end
208
+
209
+ def test_search_highlight
210
+ assert(@redisearch_client.create_index(@schema))
211
+ long_director = 'Steven ' * 80 + 'Sofia Coppola' + ' ' + 'Steven ' * 80
212
+ docs = [['id_1', ['title', 'Lost in translation', 'director', long_director, 'year', '2004']],
213
+ ['id_2', ['title', 'Ex Machina', 'director', 'Alex Garland', 'year', '2014']],
214
+ ['id_3', ['title', 'Terminator', 'director', 'James Cameron', 'year', '1984']],
215
+ ['id_4', ['title', 'Blade Runner', 'director', 'Ridley Scott', 'year', '1982']]]
216
+ assert(@redisearch_client.add_docs(docs))
217
+ matches = @redisearch_client.search('Sofia', highlight: false)
218
+ assert_equal 1, matches.count
219
+ assert_match(/^[^<]+$/, matches[0]['director'])
220
+
221
+ matches = @redisearch_client.search('Sofia', highlight: true)
222
+ assert_equal 1, matches.count
223
+ assert_match(/<b>/, matches[0]['director'])
224
+ end
225
+
192
226
  def test_index_info
193
227
  assert(@redisearch_client.create_index(@schema))
194
228
  doc = ['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: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-03 00:00:00.000000000 Z
11
+ date: 2020-11-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  A simple Ruby client library for RediSearch.
@@ -52,8 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubyforge_project:
56
- rubygems_version: 2.6.11
55
+ rubygems_version: 3.0.3
57
56
  signing_key:
58
57
  specification_version: 4
59
58
  summary: A simple Ruby client library for RediSearch