redi_search 3.0.0 → 6.0.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/.github/workflows/lint.yml +8 -4
- data/.github/workflows/tests.yml +13 -6
- data/.rubocop.yml +2 -1
- data/Appraisals +6 -6
- data/Gemfile +3 -2
- data/README.md +57 -58
- data/Rakefile +1 -0
- data/bin/console +14 -6
- data/bin/publish +2 -2
- data/gemfiles/{activerecord_52.gemfile → activerecord_60.gemfile} +2 -2
- data/gemfiles/activerecord_61.gemfile +2 -2
- data/gemfiles/{activerecord_51.gemfile → activerecord_70.gemfile} +2 -2
- data/lib/redi_search/add_field.rb +9 -15
- data/lib/redi_search/client.rb +10 -8
- data/lib/redi_search/document/display.rb +4 -4
- data/lib/redi_search/document.rb +12 -13
- data/lib/redi_search/index.rb +5 -12
- data/lib/redi_search/lazily_load.rb +2 -2
- data/lib/redi_search/log_subscriber.rb +2 -2
- data/lib/redi_search/model.rb +20 -28
- data/lib/redi_search/schema/field.rb +24 -2
- data/lib/redi_search/schema/geo_field.rb +6 -7
- data/lib/redi_search/schema/numeric_field.rb +6 -7
- data/lib/redi_search/schema/tag_field.rb +16 -8
- data/lib/redi_search/schema/text_field.rb +8 -7
- data/lib/redi_search/schema.rb +35 -22
- data/lib/redi_search/search/clauses/and.rb +0 -2
- data/lib/redi_search/search/clauses/application_clause.rb +0 -2
- data/lib/redi_search/search/clauses/boolean.rb +1 -1
- data/lib/redi_search/search/clauses/in_order.rb +0 -2
- data/lib/redi_search/search/clauses/language.rb +0 -2
- data/lib/redi_search/search/clauses/limit.rb +0 -2
- data/lib/redi_search/search/clauses/no_content.rb +0 -2
- data/lib/redi_search/search/clauses/no_stop_words.rb +0 -2
- data/lib/redi_search/search/clauses/or.rb +0 -2
- data/lib/redi_search/search/clauses/return.rb +0 -2
- data/lib/redi_search/search/clauses/slop.rb +0 -2
- data/lib/redi_search/search/clauses/sort_by.rb +0 -2
- data/lib/redi_search/search/clauses/verbatim.rb +0 -2
- data/lib/redi_search/search/clauses/where.rb +1 -1
- data/lib/redi_search/search/clauses/with_scores.rb +0 -2
- data/lib/redi_search/search/clauses.rb +0 -16
- data/lib/redi_search/search/result.rb +2 -2
- data/lib/redi_search/search/term.rb +16 -9
- data/lib/redi_search/search.rb +1 -7
- data/lib/redi_search/spellcheck/result.rb +4 -4
- data/lib/redi_search/spellcheck.rb +3 -7
- data/lib/redi_search/validatable.rb +0 -4
- data/lib/redi_search/validations/numericality.rb +0 -2
- data/lib/redi_search/version.rb +1 -1
- data/lib/redi_search.rb +3 -7
- data/redi_search.gemspec +11 -8
- metadata +24 -9
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "redi_search/validatable"
|
4
|
-
|
5
3
|
module RediSearch
|
6
4
|
class Search
|
7
5
|
class Term
|
@@ -12,16 +10,17 @@ module RediSearch
|
|
12
10
|
validates_inclusion_of :option, within: %i(fuzziness optional prefix),
|
13
11
|
allow_nil: true
|
14
12
|
|
15
|
-
def initialize(term, **options)
|
16
|
-
@term
|
13
|
+
def initialize(term, field = nil, **options)
|
14
|
+
@term = term
|
15
|
+
@field = field
|
17
16
|
@options = options
|
18
17
|
|
19
18
|
validate!
|
20
19
|
end
|
21
20
|
|
22
21
|
def to_s
|
23
|
-
if
|
24
|
-
|
22
|
+
if term.is_a?(Range) then stringify_range
|
23
|
+
elsif !field.nil? && field.tag? then stringify_tag
|
25
24
|
else
|
26
25
|
stringify_query
|
27
26
|
end
|
@@ -29,7 +28,7 @@ module RediSearch
|
|
29
28
|
|
30
29
|
private
|
31
30
|
|
32
|
-
attr_accessor :term, :options
|
31
|
+
attr_accessor :term, :field, :options
|
33
32
|
|
34
33
|
def fuzziness
|
35
34
|
@fuzziness ||= options[:fuzziness]
|
@@ -52,7 +51,7 @@ module RediSearch
|
|
52
51
|
end
|
53
52
|
|
54
53
|
def stringify_query
|
55
|
-
|
54
|
+
term.to_s.
|
56
55
|
tr("`", "\`").
|
57
56
|
yield_self { |str| "#{fuzzy_operator}#{str}#{fuzzy_operator}" }.
|
58
57
|
yield_self { |str| "#{optional_operator}#{str}" }.
|
@@ -60,8 +59,16 @@ module RediSearch
|
|
60
59
|
yield_self { |str| "`#{str}`" }
|
61
60
|
end
|
62
61
|
|
62
|
+
def stringify_tag
|
63
|
+
if term.is_a?(Array)
|
64
|
+
"{ #{term.join(' | ')} }"
|
65
|
+
else
|
66
|
+
"{ #{term} }"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
63
70
|
def stringify_range
|
64
|
-
first, last =
|
71
|
+
first, last = term.first, term.last
|
65
72
|
first = "-inf" if first == -Float::INFINITY
|
66
73
|
last = "+inf" if last == Float::INFINITY
|
67
74
|
|
data/lib/redi_search/search.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "redi_search/lazily_load"
|
4
|
-
|
5
|
-
require "redi_search/search/clauses"
|
6
|
-
require "redi_search/search/term"
|
7
|
-
require "redi_search/search/result"
|
8
|
-
|
9
3
|
module RediSearch
|
10
4
|
class Search
|
11
5
|
extend Forwardable
|
@@ -54,7 +48,7 @@ module RediSearch
|
|
54
48
|
end
|
55
49
|
|
56
50
|
def parse_response(response)
|
57
|
-
@documents = Result.new(self, response[0], response[1
|
51
|
+
@documents = Result.new(self, response[0], response[1..])
|
58
52
|
end
|
59
53
|
|
60
54
|
def valid?
|
@@ -15,14 +15,14 @@ module RediSearch
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def inspect
|
18
|
-
inspection = %w(term suggestions).
|
18
|
+
inspection = %w(term suggestions).filter_map do |field_name|
|
19
19
|
"#{field_name}: #{public_send(field_name)}"
|
20
|
-
end.
|
20
|
+
end.join(", ")
|
21
21
|
|
22
22
|
"#<#{self.class} #{inspection}>"
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
# :nocov:
|
26
26
|
def pretty_print(printer) # rubocop:disable Metrics/MethodLength
|
27
27
|
printer.object_address_group(self) do
|
28
28
|
printer.seplist(
|
@@ -38,7 +38,7 @@ module RediSearch
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
# :nocov:
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "redi_search/lazily_load"
|
4
|
-
require "redi_search/spellcheck/result"
|
5
|
-
require "redi_search/validatable"
|
6
|
-
|
7
3
|
module RediSearch
|
8
4
|
class Spellcheck
|
9
5
|
include LazilyLoad
|
@@ -27,7 +23,7 @@ module RediSearch
|
|
27
23
|
end
|
28
24
|
|
29
25
|
def parsed_terms
|
30
|
-
terms.split(Regexp.union(",.<>{}[]\"':;!@#$%^&*()-+=~\s".
|
26
|
+
terms.split(Regexp.union(",.<>{}[]\"':;!@#$%^&*()-+=~\s".chars))
|
31
27
|
end
|
32
28
|
|
33
29
|
def execute
|
@@ -41,9 +37,9 @@ module RediSearch
|
|
41
37
|
end
|
42
38
|
|
43
39
|
def parse_response(response)
|
44
|
-
suggestions = response.
|
40
|
+
suggestions = response.to_h do |suggestion|
|
45
41
|
suggestion[1..2]
|
46
|
-
end
|
42
|
+
end
|
47
43
|
|
48
44
|
@documents = parsed_terms.map do |term|
|
49
45
|
Result.new(term, suggestions[term] || [])
|
data/lib/redi_search/version.rb
CHANGED
data/lib/redi_search.rb
CHANGED
@@ -4,14 +4,10 @@ require "delegate"
|
|
4
4
|
require "forwardable"
|
5
5
|
require "redis"
|
6
6
|
require "active_support/lazy_load_hooks"
|
7
|
+
require "zeitwerk"
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require "redi_search/model"
|
12
|
-
require "redi_search/index"
|
13
|
-
require "redi_search/log_subscriber"
|
14
|
-
require "redi_search/document"
|
9
|
+
loader = Zeitwerk::Loader.for_gem
|
10
|
+
loader.setup
|
15
11
|
|
16
12
|
module RediSearch
|
17
13
|
class << self
|
data/redi_search.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = "redi_search"
|
9
9
|
spec.version = RediSearch::VERSION
|
10
10
|
spec.authors = "Nick Pezza"
|
11
|
-
spec.email = "
|
11
|
+
spec.email = "pezza@hey.com"
|
12
12
|
|
13
13
|
spec.summary = %q(RediSearch ruby wrapper that can integrate with Rails)
|
14
14
|
spec.homepage = "https://github.com/npezza93/redi_search"
|
@@ -18,16 +18,19 @@ Gem::Specification.new do |spec|
|
|
18
18
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
|
19
19
|
end
|
20
20
|
|
21
|
-
spec.metadata
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
"
|
21
|
+
spec.metadata = {
|
22
|
+
"rubygems_mfa_required" => "true",
|
23
|
+
"github_repo" => "ssh://github.com/npezza93/redi_search",
|
24
|
+
"homepage_uri" => spec.homepage,
|
25
|
+
"source_code_uri" => spec.homepage,
|
26
|
+
"changelog_uri" => "https://github.com/npezza93/redi_search/releases",
|
27
|
+
}
|
26
28
|
|
27
|
-
spec.required_ruby_version = ">= 2.
|
29
|
+
spec.required_ruby_version = ">= 2.7.0"
|
28
30
|
|
29
|
-
spec.add_runtime_dependency "activesupport", ">= 5.1", "<
|
31
|
+
spec.add_runtime_dependency "activesupport", ">= 5.1", "< 7.1"
|
30
32
|
spec.add_runtime_dependency "redis", ">= 4.0", "< 5.0"
|
33
|
+
spec.add_runtime_dependency "zeitwerk"
|
31
34
|
|
32
35
|
spec.add_development_dependency "bundler", ">= 1.17", "< 3"
|
33
36
|
spec.add_development_dependency "minitest", "~> 5.0"
|
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:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pezza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: redis
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '5.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: zeitwerk
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: bundler
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +113,7 @@ dependencies:
|
|
99
113
|
- !ruby/object:Gem::Version
|
100
114
|
version: '13.0'
|
101
115
|
description:
|
102
|
-
email:
|
116
|
+
email: pezza@hey.com
|
103
117
|
executables: []
|
104
118
|
extensions: []
|
105
119
|
extra_rdoc_files: []
|
@@ -121,9 +135,9 @@ files:
|
|
121
135
|
- bin/publish
|
122
136
|
- bin/setup
|
123
137
|
- gemfiles/.bundle/config
|
124
|
-
- gemfiles/
|
125
|
-
- gemfiles/activerecord_52.gemfile
|
138
|
+
- gemfiles/activerecord_60.gemfile
|
126
139
|
- gemfiles/activerecord_61.gemfile
|
140
|
+
- gemfiles/activerecord_70.gemfile
|
127
141
|
- lib/redi_search.rb
|
128
142
|
- lib/redi_search/add_field.rb
|
129
143
|
- lib/redi_search/client.rb
|
@@ -176,6 +190,7 @@ homepage: https://github.com/npezza93/redi_search
|
|
176
190
|
licenses:
|
177
191
|
- MIT
|
178
192
|
metadata:
|
193
|
+
rubygems_mfa_required: 'true'
|
179
194
|
github_repo: ssh://github.com/npezza93/redi_search
|
180
195
|
homepage_uri: https://github.com/npezza93/redi_search
|
181
196
|
source_code_uri: https://github.com/npezza93/redi_search
|
@@ -188,14 +203,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
203
|
requirements:
|
189
204
|
- - ">="
|
190
205
|
- !ruby/object:Gem::Version
|
191
|
-
version: 2.
|
206
|
+
version: 2.7.0
|
192
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
208
|
requirements:
|
194
209
|
- - ">="
|
195
210
|
- !ruby/object:Gem::Version
|
196
211
|
version: '0'
|
197
212
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
213
|
+
rubygems_version: 3.2.22
|
199
214
|
signing_key:
|
200
215
|
specification_version: 4
|
201
216
|
summary: RediSearch ruby wrapper that can integrate with Rails
|