redi_search 6.0.0 → 6.0.1
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/.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/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: 7bb651cd81b7d83eb69c31a88bc6680c47083c324bd0a7e2670081fa479b12fa
|
4
|
+
data.tar.gz: '037638518a882a238acf3f81c08e2598733ecfc3b8571a9e93e37c894f8b73aa'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3ddf47605dee892bdf811d2bcab81ce503431532ae481e1c1a49f611061c5b43a01d2d45325901c658e14a4ceb706b743411439f14bd235ed44fddecaf6716
|
7
|
+
data.tar.gz: 1879a477cae2f84072f28d20d88ce4d6e61b1b28ea4e2966cec01ebc14e9fed61b45b43a3688eacb0979f31647b5c66ff55c460f852a68b8154348effd0c8ee0
|
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
|
-

|
10
|
-
[](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
|
@@ -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.0.
|
4
|
+
version: 6.0.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-15 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
|