typesense 3.0.0.rc1 → 3.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/tests.yml +4 -4
- data/README.md +1 -0
- data/lib/typesense/client.rb +2 -1
- data/lib/typesense/stemming.rb +15 -0
- data/lib/typesense/stemming_dictionaries.rb +49 -0
- data/lib/typesense/stemming_dictionary.rb +20 -0
- data/lib/typesense/version.rb +1 -1
- data/lib/typesense.rb +3 -0
- data/typesense.gemspec +1 -0
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3efcebcc5a0475181b09faa3e0b7b1c08886c5b3ade298f51dbb1743b9d9cc70
|
4
|
+
data.tar.gz: 70e5a40fb8481c70d04f53196ede21112df3bf0e903202e73d2aab4fd4cd7d9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fc680cf4defb9ad733da576c56f7ce127e9622d44ee0b3912cd5f139c1fb373ac1c1475da59bd191ec943f6991215966b951dde34be84fc2d85496b554e3410
|
7
|
+
data.tar.gz: e5c66ae5868171ccf75a9800bc52b3cc539434480285232b1debbb84a79e22f1ad2b404c9951f4085dfaa99ffd87f1043b96b2a5f24c7dfee16392ce25f05dfe
|
data/.github/workflows/tests.yml
CHANGED
@@ -10,10 +10,10 @@ jobs:
|
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
strategy:
|
12
12
|
matrix:
|
13
|
-
ruby-version: ['
|
13
|
+
ruby-version: ['3.0', '3.2', '3.3']
|
14
14
|
services:
|
15
15
|
typesense:
|
16
|
-
image: typesense/typesense:
|
16
|
+
image: typesense/typesense:28.0
|
17
17
|
ports:
|
18
18
|
- 8108:8108
|
19
19
|
volumes:
|
@@ -37,8 +37,8 @@ jobs:
|
|
37
37
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
38
38
|
- run: bundle exec rubocop
|
39
39
|
- run: bundle exec rspec --format documentation
|
40
|
-
- uses: actions/upload-artifact@
|
40
|
+
- uses: actions/upload-artifact@v4
|
41
41
|
with:
|
42
|
-
name: coverage
|
42
|
+
name: coverage-ruby-${{ matrix.ruby-version }}
|
43
43
|
path: coverage/
|
44
44
|
retention-days: 1
|
data/README.md
CHANGED
@@ -33,6 +33,7 @@ Tests are also a good place to know how the the library works internally: [spec]
|
|
33
33
|
|
34
34
|
| Typesense Server | typesense-ruby |
|
35
35
|
|------------------|----------------|
|
36
|
+
| \>= v28.0 | \>= v3.0.0 |
|
36
37
|
| \>= v0.25.0 | \>= v1.0.0 |
|
37
38
|
| \>= v0.23.0 | \>= v0.14.0 |
|
38
39
|
| \>= v0.21.0 | \>= v0.13.0 |
|
data/lib/typesense/client.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Typesense
|
4
4
|
class Client
|
5
5
|
attr_reader :configuration, :collections, :aliases, :keys, :debug, :health, :metrics, :stats, :operations,
|
6
|
-
:multi_search, :analytics, :presets
|
6
|
+
:multi_search, :analytics, :presets, :stemming
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@configuration = Configuration.new(options)
|
@@ -18,6 +18,7 @@ module Typesense
|
|
18
18
|
@stats = Stats.new(@api_call)
|
19
19
|
@operations = Operations.new(@api_call)
|
20
20
|
@analytics = Analytics.new(@api_call)
|
21
|
+
@stemming = Stemming.new(@api_call)
|
21
22
|
@presets = Presets.new(@api_call)
|
22
23
|
end
|
23
24
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Typesense
|
4
|
+
class Stemming
|
5
|
+
RESOURCE_PATH = '/stemming'
|
6
|
+
|
7
|
+
def initialize(api_call)
|
8
|
+
@api_call = api_call
|
9
|
+
end
|
10
|
+
|
11
|
+
def dictionaries
|
12
|
+
@dictionaries ||= StemmingDictionaries.new(@api_call)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Typesense
|
4
|
+
class StemmingDictionaries
|
5
|
+
RESOURCE_PATH = '/stemming/dictionaries'
|
6
|
+
|
7
|
+
def initialize(api_call)
|
8
|
+
@api_call = api_call
|
9
|
+
@dictionaries = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def upsert(dict_id, words_and_roots_combinations)
|
13
|
+
words_and_roots_combinations_in_jsonl = if words_and_roots_combinations.is_a?(Array)
|
14
|
+
words_and_roots_combinations.map { |combo| Oj.dump(combo, mode: :compat) }.join("\n")
|
15
|
+
else
|
16
|
+
words_and_roots_combinations
|
17
|
+
end
|
18
|
+
|
19
|
+
result_in_jsonl = @api_call.perform_request(
|
20
|
+
'post',
|
21
|
+
endpoint_path('import'),
|
22
|
+
query_parameters: { id: dict_id },
|
23
|
+
body_parameters: words_and_roots_combinations_in_jsonl,
|
24
|
+
additional_headers: { 'Content-Type' => 'text/plain' }
|
25
|
+
)
|
26
|
+
|
27
|
+
if words_and_roots_combinations.is_a?(Array)
|
28
|
+
result_in_jsonl.split("\n").map { |r| Oj.load(r) }
|
29
|
+
else
|
30
|
+
result_in_jsonl
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def retrieve
|
35
|
+
response = @api_call.get(endpoint_path)
|
36
|
+
response || { 'dictionaries' => [] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def [](dict_id)
|
40
|
+
@dictionaries[dict_id] ||= StemmingDictionary.new(dict_id, @api_call)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def endpoint_path(operation = nil)
|
46
|
+
"#{StemmingDictionaries::RESOURCE_PATH}#{operation.nil? ? '' : "/#{URI.encode_www_form_component(operation)}"}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Typesense
|
4
|
+
class StemmingDictionary
|
5
|
+
def initialize(id, api_call)
|
6
|
+
@dict_id = id
|
7
|
+
@api_call = api_call
|
8
|
+
end
|
9
|
+
|
10
|
+
def retrieve
|
11
|
+
@api_call.get(endpoint_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def endpoint_path
|
17
|
+
"#{StemmingDictionaries::RESOURCE_PATH}/#{URI.encode_www_form_component(@dict_id)}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/typesense/version.rb
CHANGED
data/lib/typesense.rb
CHANGED
@@ -32,3 +32,6 @@ require_relative 'typesense/metrics'
|
|
32
32
|
require_relative 'typesense/stats'
|
33
33
|
require_relative 'typesense/operations'
|
34
34
|
require_relative 'typesense/error'
|
35
|
+
require_relative 'typesense/stemming'
|
36
|
+
require_relative 'typesense/stemming_dictionaries'
|
37
|
+
require_relative 'typesense/stemming_dictionary'
|
data/typesense.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
|
+
spec.add_dependency 'base64', '~> 0.2.0'
|
29
30
|
spec.add_dependency 'faraday', '~> 2.8'
|
30
31
|
spec.add_dependency 'oj', '~> 3.16'
|
31
32
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typesense
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Typesense, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base64
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: faraday
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +105,9 @@ files:
|
|
91
105
|
- lib/typesense/preset.rb
|
92
106
|
- lib/typesense/presets.rb
|
93
107
|
- lib/typesense/stats.rb
|
108
|
+
- lib/typesense/stemming.rb
|
109
|
+
- lib/typesense/stemming_dictionaries.rb
|
110
|
+
- lib/typesense/stemming_dictionary.rb
|
94
111
|
- lib/typesense/synonym.rb
|
95
112
|
- lib/typesense/synonyms.rb
|
96
113
|
- lib/typesense/version.rb
|
@@ -111,9 +128,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
128
|
version: '2.7'
|
112
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
130
|
requirements:
|
114
|
-
- - "
|
131
|
+
- - ">="
|
115
132
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
133
|
+
version: '0'
|
117
134
|
requirements: []
|
118
135
|
rubygems_version: 3.4.10
|
119
136
|
signing_key:
|