typesense 3.0.0.rc1 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 207a723a469821c92408584d89b0d74db1c705e472ab1f7f238cea1640816993
4
- data.tar.gz: ce2df2d51c341f60c5f2626810b71d3250e03640ae01cfe5e74cfc0be262ee65
3
+ metadata.gz: 0b16a7f00600eadbcf0769d6eec67994e52d89784d4d5900dbbb2cd4ea23b364
4
+ data.tar.gz: 4a278a32c83aaff66f7fb23f8e9688f222604c5f90f25236a3eb55b1416247c5
5
5
  SHA512:
6
- metadata.gz: '08f5e7ba0388270bb7f510ea9d8150d159673d3cedee6fbaa9e867e5591716add353359af503754aa8da1d75f9732522df106def8a98ce77dae5d1f9ba80b037'
7
- data.tar.gz: 58e734bcf1a05efb399e32ceed24827dac1818c9ea669d9b1d99c52707a60854af2305c3275ae863c5cca88fa0142b53f25e53e3c816ed44d4f0c0eb69e1d164
6
+ metadata.gz: 179ee2a5b661699d0fc7eb311f92dcd1ec913ed9aae99a13124f96ad3ef314ac872a1db4cee70f0d8abd84011a8887cf7d188bdd048219151d7f843700763f3b
7
+ data.tar.gz: 4aedda18915d7c2f3f17626d3d9b90cc1ddd4fa81f828536235d9775fcc1e9de0c838bde2988f3de38b337ab1a7b6e5b489547e07cfa9101754cb5a0ce2a05aa
@@ -10,10 +10,10 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
  strategy:
12
12
  matrix:
13
- ruby-version: ['2.7', '3.0', '3.2']
13
+ ruby-version: ['3.0', '3.2', '3.3']
14
14
  services:
15
15
  typesense:
16
- image: typesense/typesense:27.1
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@v3
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 |
@@ -145,6 +145,16 @@ ap collection
145
145
  # "num_documents" => 0
146
146
  # }
147
147
 
148
+ ###
149
+ # Truncate a collection
150
+ # Deletion returns the number of documents deleted
151
+ collection = @typesense.collections['companies'].truncate
152
+ ap collection
153
+
154
+ # {
155
+ # "num_deleted": 125
156
+ # }
157
+
148
158
  # Let's create the collection again for use in our remaining examples
149
159
  @typesense.collections.create(schema)
150
160
 
@@ -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
@@ -9,7 +9,7 @@ module Typesense
9
9
  @api_call = api_call
10
10
  @documents = Documents.new(@name, @api_call)
11
11
  @overrides = Overrides.new(@name, @api_call)
12
- @synonyms = Synonyms.new(@name, @api_call)
12
+ @synonyms = Synonyms.new(@name, @api_call)
13
13
  end
14
14
 
15
15
  def retrieve
@@ -72,6 +72,10 @@ module Typesense
72
72
  @api_call.delete(endpoint_path, query_parameters)
73
73
  end
74
74
 
75
+ def truncate
76
+ @api_call.delete(endpoint_path, { truncate: true })
77
+ end
78
+
75
79
  private
76
80
 
77
81
  def endpoint_path(operation = nil)
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Typesense
4
- VERSION = '3.0.0.rc1'
4
+ VERSION = '3.0.1'
5
5
  end
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.rc1
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Typesense, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-20 00:00:00.000000000 Z
11
+ date: 2025-02-24 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: 1.3.1
133
+ version: '0'
117
134
  requirements: []
118
135
  rubygems_version: 3.4.10
119
136
  signing_key: