redi_search 6.0.0 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +1 -1
- data/.rubocop.yml +0 -4
- data/Gemfile +1 -1
- data/README.md +0 -3
- data/lib/redi_search/lazily_load.rb +1 -1
- data/lib/redi_search/log_subscriber.rb +4 -0
- data/lib/redi_search/model.rb +2 -2
- data/lib/redi_search/schema/field.rb +4 -4
- data/lib/redi_search/schema/numeric_field.rb +8 -0
- data/lib/redi_search/schema/tag_field.rb +2 -2
- data/lib/redi_search/schema.rb +1 -1
- data/lib/redi_search/search/result.rb +11 -1
- data/lib/redi_search/search/term.rb +6 -10
- data/lib/redi_search/spellcheck.rb +1 -1
- data/lib/redi_search/version.rb +1 -1
- data/lib/redi_search.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 779fa58ead3f1109819deb5b8884eb9bbcfccbd34017a8288450f19077abdac6
|
4
|
+
data.tar.gz: caad3d0dec14dfea3ad2098d406a90c1c3f2afa99c416379726f4361f41c7eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 778f9c57db20bde51dc953baa1c73deb54f2fe4c7783c017e3f5c76ab1c9b467bc10359ae1614e0fab512acfb170e3f3565edb600b87d580a6e7d82c766875b9
|
7
|
+
data.tar.gz: 850c1f47ffadcadb6fd98de2fc7a550d1d770179c14e99ffd1fa81e6a9147c6dcbc632f6e798c53437d4997b381dbc273263000b33472a4dd89991d4dccf1433
|
data/.github/workflows/tests.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -619,10 +619,6 @@ Lint/BinaryOperatorWithIdenticalOperands:
|
|
619
619
|
Description: Checks for comparison of something with itself.
|
620
620
|
Enabled: true
|
621
621
|
|
622
|
-
Lint/UselessElseWithoutRescue:
|
623
|
-
Description: Checks for useless `else` in `begin..end` without `rescue`.
|
624
|
-
Enabled: true
|
625
|
-
|
626
622
|
Lint/ReturnInVoidContext:
|
627
623
|
Description: Checks for return in void context.
|
628
624
|
Enabled: true
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,9 +6,6 @@
|
|
6
6
|
|
7
7
|
# RediSearch
|
8
8
|
|
9
|
-
![Build Status](https://github.com/npezza93/redi_search/workflows/tests/badge.svg)
|
10
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/c6437acac5684de2549d/maintainability)](https://codeclimate.com/github/npezza93/redi_search/maintainability)
|
11
|
-
|
12
9
|
A simple, but powerful, Ruby wrapper around RediSearch, a search engine on top of
|
13
10
|
Redis.
|
14
11
|
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support/version"
|
3
4
|
require "active_support/log_subscriber"
|
5
|
+
if ActiveSupport::VERSION::MAJOR > 6
|
6
|
+
require "active_support/isolated_execution_state"
|
7
|
+
end
|
4
8
|
|
5
9
|
module RediSearch
|
6
10
|
class LogSubscriber < ActiveSupport::LogSubscriber
|
data/lib/redi_search/model.rb
CHANGED
@@ -43,8 +43,8 @@ module RediSearch
|
|
43
43
|
search_index.spellcheck(term, distance: distance)
|
44
44
|
end
|
45
45
|
|
46
|
-
def reindex(recreate: false, only: [])
|
47
|
-
search_import.find_in_batches.all? do |group|
|
46
|
+
def reindex(recreate: false, only: [], batch_size: 1000)
|
47
|
+
search_import.find_in_batches(batch_size: batch_size).all? do |group|
|
48
48
|
search_index.reindex(
|
49
49
|
group.map { |record| record.search_document(only: only) },
|
50
50
|
recreate: recreate
|
@@ -11,6 +11,10 @@ module RediSearch
|
|
11
11
|
value
|
12
12
|
end
|
13
13
|
|
14
|
+
def cast(value)
|
15
|
+
value
|
16
|
+
end
|
17
|
+
|
14
18
|
def serialize(record)
|
15
19
|
if value_block
|
16
20
|
record.instance_exec(&value_block)
|
@@ -19,10 +23,6 @@ module RediSearch
|
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
22
|
-
def tag?
|
23
|
-
false
|
24
|
-
end
|
25
|
-
|
26
26
|
private
|
27
27
|
|
28
28
|
attr_reader :value_block
|
data/lib/redi_search/schema.rb
CHANGED
@@ -21,6 +21,8 @@ module RediSearch
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def_delegators :results, :each, :empty?, :[], :last
|
24
|
+
def_delegator :search, :index
|
25
|
+
def_delegator :index, :schema
|
24
26
|
|
25
27
|
def inspect
|
26
28
|
results
|
@@ -58,9 +60,17 @@ module RediSearch
|
|
58
60
|
fields = slice.last unless no_content?
|
59
61
|
score = slice[1].to_f if with_scores?
|
60
62
|
|
61
|
-
|
63
|
+
parse_result(document_id, fields, score)
|
62
64
|
end
|
63
65
|
end
|
66
|
+
|
67
|
+
def parse_result(document_id, fields, score)
|
68
|
+
field_values = fields.to_a.each_slice(2).to_h do |name, value|
|
69
|
+
[name, schema[name].cast(value)]
|
70
|
+
end
|
71
|
+
|
72
|
+
Document.new(search.index, document_id, field_values, score)
|
73
|
+
end
|
64
74
|
end
|
65
75
|
end
|
66
76
|
end
|
@@ -20,7 +20,7 @@ module RediSearch
|
|
20
20
|
|
21
21
|
def to_s
|
22
22
|
if term.is_a?(Range) then stringify_range
|
23
|
-
elsif
|
23
|
+
elsif field.is_a?(Schema::TagField) then stringify_tag
|
24
24
|
else
|
25
25
|
stringify_query
|
26
26
|
end
|
@@ -53,18 +53,14 @@ module RediSearch
|
|
53
53
|
def stringify_query
|
54
54
|
term.to_s.
|
55
55
|
tr("`", "\`").
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
then { |str| "#{fuzzy_operator}#{str}#{fuzzy_operator}" }.
|
57
|
+
then { |str| "#{optional_operator}#{str}" }.
|
58
|
+
then { |str| "#{str}#{prefix_operator}" }.
|
59
|
+
then { |str| "`#{str}`" }
|
60
60
|
end
|
61
61
|
|
62
62
|
def stringify_tag
|
63
|
-
|
64
|
-
"{ #{term.join(' | ')} }"
|
65
|
-
else
|
66
|
-
"{ #{term} }"
|
67
|
-
end
|
63
|
+
"{ #{Array(term).join(' | ')} }"
|
68
64
|
end
|
69
65
|
|
70
66
|
def stringify_range
|
data/lib/redi_search/version.rb
CHANGED
data/lib/redi_search.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redi_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pezza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
213
|
+
rubygems_version: 3.3.7
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: RediSearch ruby wrapper that can integrate with Rails
|