typesense 3.1.0 → 4.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/.gitignore +1 -0
- data/lib/typesense/analytics_rules.rb +1 -1
- data/lib/typesense/api_call.rb +3 -3
- data/lib/typesense/client.rb +2 -1
- data/lib/typesense/documents.rb +5 -5
- data/lib/typesense/nl_search_model.rb +28 -0
- data/lib/typesense/nl_search_models.rb +24 -0
- data/lib/typesense/overrides.rb +1 -1
- data/lib/typesense/presets.rb +1 -1
- data/lib/typesense/stemming_dictionaries.rb +3 -3
- data/lib/typesense/synonyms.rb +1 -1
- data/lib/typesense/version.rb +1 -1
- data/lib/typesense.rb +2 -0
- data/typesense.gemspec +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eabea293f2c90bcda7240c54cc821d661ed84de8cf8acdd010e0ab664b9f231a
|
4
|
+
data.tar.gz: 20d6adb7c931b511ccac43dab48a894868268e602aafc7659fd43742396052ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1f78ab07a2a81ff13fa21b7d9b49c4bf241c694703798fa26091767f0229416a821c91147296dab5c834c0aeaa39e337b395128f0b1b4f6fc7cd3b94bebc664
|
7
|
+
data.tar.gz: cf150fb6a61a3b0586de8d44e94ae38e9968cf59525bbb1dbd003ee96a45230f42bedb6419627e58cedb75bfc0969db10405e859881bbf4b1d7bf5d7bfa0d113
|
data/.gitignore
CHANGED
@@ -24,7 +24,7 @@ module Typesense
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def endpoint_path(operation = nil)
|
27
|
-
"#{AnalyticsRules::RESOURCE_PATH}#{
|
27
|
+
"#{AnalyticsRules::RESOURCE_PATH}#{"/#{URI.encode_www_form_component(operation)}" unless operation.nil?}"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/typesense/api_call.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'faraday'
|
4
|
-
require '
|
4
|
+
require 'json'
|
5
5
|
|
6
6
|
module Typesense
|
7
7
|
class ApiCall
|
@@ -81,7 +81,7 @@ module Typesense
|
|
81
81
|
req.params = query_parameters unless query_parameters.nil?
|
82
82
|
unless body_parameters.nil?
|
83
83
|
body = body_parameters
|
84
|
-
body =
|
84
|
+
body = JSON.dump(body_parameters) if headers['Content-Type'] == 'application/json'
|
85
85
|
req.body = body
|
86
86
|
end
|
87
87
|
end
|
@@ -90,7 +90,7 @@ module Typesense
|
|
90
90
|
@logger.debug "Request #{method}:#{uri_for(endpoint, node)} to Node #{node[:index]} was successfully made (at the network layer). response.status was #{response.status}."
|
91
91
|
|
92
92
|
parsed_response = if response.headers && (response.headers['content-type'] || '').include?('application/json')
|
93
|
-
|
93
|
+
JSON.parse(response.body)
|
94
94
|
else
|
95
95
|
response.body
|
96
96
|
end
|
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, :stemming
|
6
|
+
:multi_search, :analytics, :presets, :stemming, :nl_search_models
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@configuration = Configuration.new(options)
|
@@ -20,6 +20,7 @@ module Typesense
|
|
20
20
|
@analytics = Analytics.new(@api_call)
|
21
21
|
@stemming = Stemming.new(@api_call)
|
22
22
|
@presets = Presets.new(@api_call)
|
23
|
+
@nl_search_models = NlSearchModels.new(@api_call)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
data/lib/typesense/documents.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'json'
|
4
4
|
|
5
5
|
module Typesense
|
6
6
|
class Documents
|
@@ -36,7 +36,7 @@ module Typesense
|
|
36
36
|
# @param [Array,String] documents An array of document hashes or a JSONL string of documents.
|
37
37
|
def import(documents, options = {})
|
38
38
|
documents_in_jsonl_format = if documents.is_a?(Array)
|
39
|
-
documents.map { |document|
|
39
|
+
documents.map { |document| JSON.dump(document) }.join("\n")
|
40
40
|
else
|
41
41
|
documents
|
42
42
|
end
|
@@ -51,8 +51,8 @@ module Typesense
|
|
51
51
|
|
52
52
|
if documents.is_a?(Array)
|
53
53
|
results_in_jsonl_format.split("\n").map do |r|
|
54
|
-
|
55
|
-
rescue
|
54
|
+
JSON.parse(r)
|
55
|
+
rescue JSON::ParserError => e
|
56
56
|
{
|
57
57
|
'success' => false,
|
58
58
|
'exception' => e.class.name,
|
@@ -88,7 +88,7 @@ module Typesense
|
|
88
88
|
private
|
89
89
|
|
90
90
|
def endpoint_path(operation = nil)
|
91
|
-
"#{Collections::RESOURCE_PATH}/#{URI.encode_www_form_component(@collection_name)}#{Documents::RESOURCE_PATH}#{
|
91
|
+
"#{Collections::RESOURCE_PATH}/#{URI.encode_www_form_component(@collection_name)}#{Documents::RESOURCE_PATH}#{"/#{operation}" unless operation.nil?}"
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Typesense
|
4
|
+
class NlSearchModel
|
5
|
+
def initialize(model_id, api_call)
|
6
|
+
@model_id = model_id
|
7
|
+
@api_call = api_call
|
8
|
+
end
|
9
|
+
|
10
|
+
def retrieve
|
11
|
+
@api_call.get(endpoint_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def update(update_schema)
|
15
|
+
@api_call.put(endpoint_path, update_schema)
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete
|
19
|
+
@api_call.delete(endpoint_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def endpoint_path
|
25
|
+
"#{NlSearchModels::RESOURCE_PATH}/#{URI.encode_www_form_component(@model_id)}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Typesense
|
4
|
+
class NlSearchModels
|
5
|
+
RESOURCE_PATH = '/nl_search_models'
|
6
|
+
|
7
|
+
def initialize(api_call)
|
8
|
+
@api_call = api_call
|
9
|
+
@nl_search_models = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(schema)
|
13
|
+
@api_call.post(RESOURCE_PATH, schema)
|
14
|
+
end
|
15
|
+
|
16
|
+
def retrieve
|
17
|
+
@api_call.get(RESOURCE_PATH)
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](model_id)
|
21
|
+
@nl_search_models[model_id] ||= NlSearchModel.new(model_id, @api_call)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/typesense/overrides.rb
CHANGED
@@ -25,7 +25,7 @@ module Typesense
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def endpoint_path(operation = nil)
|
28
|
-
"#{Collections::RESOURCE_PATH}/#{URI.encode_www_form_component(@collection_name)}#{Overrides::RESOURCE_PATH}#{
|
28
|
+
"#{Collections::RESOURCE_PATH}/#{URI.encode_www_form_component(@collection_name)}#{Overrides::RESOURCE_PATH}#{"/#{URI.encode_www_form_component(operation)}" unless operation.nil?}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/typesense/presets.rb
CHANGED
@@ -24,7 +24,7 @@ module Typesense
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def endpoint_path(operation = nil)
|
27
|
-
"#{Presets::RESOURCE_PATH}#{
|
27
|
+
"#{Presets::RESOURCE_PATH}#{"/#{URI.encode_www_form_component(operation)}" unless operation.nil?}"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -11,7 +11,7 @@ module Typesense
|
|
11
11
|
|
12
12
|
def upsert(dict_id, words_and_roots_combinations)
|
13
13
|
words_and_roots_combinations_in_jsonl = if words_and_roots_combinations.is_a?(Array)
|
14
|
-
words_and_roots_combinations.map { |combo|
|
14
|
+
words_and_roots_combinations.map { |combo| JSON.dump(combo) }.join("\n")
|
15
15
|
else
|
16
16
|
words_and_roots_combinations
|
17
17
|
end
|
@@ -25,7 +25,7 @@ module Typesense
|
|
25
25
|
)
|
26
26
|
|
27
27
|
if words_and_roots_combinations.is_a?(Array)
|
28
|
-
result_in_jsonl.split("\n").map { |r|
|
28
|
+
result_in_jsonl.split("\n").map { |r| JSON.parse(r) }
|
29
29
|
else
|
30
30
|
result_in_jsonl
|
31
31
|
end
|
@@ -43,7 +43,7 @@ module Typesense
|
|
43
43
|
private
|
44
44
|
|
45
45
|
def endpoint_path(operation = nil)
|
46
|
-
"#{StemmingDictionaries::RESOURCE_PATH}#{
|
46
|
+
"#{StemmingDictionaries::RESOURCE_PATH}#{"/#{URI.encode_www_form_component(operation)}" unless operation.nil?}"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/lib/typesense/synonyms.rb
CHANGED
@@ -25,7 +25,7 @@ module Typesense
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def endpoint_path(operation = nil)
|
28
|
-
"#{Collections::RESOURCE_PATH}/#{URI.encode_www_form_component(@collection_name)}#{Synonyms::RESOURCE_PATH}#{
|
28
|
+
"#{Collections::RESOURCE_PATH}/#{URI.encode_www_form_component(@collection_name)}#{Synonyms::RESOURCE_PATH}#{"/#{URI.encode_www_form_component(operation)}" unless operation.nil?}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/typesense/version.rb
CHANGED
data/lib/typesense.rb
CHANGED
@@ -35,3 +35,5 @@ require_relative 'typesense/error'
|
|
35
35
|
require_relative 'typesense/stemming'
|
36
36
|
require_relative 'typesense/stemming_dictionaries'
|
37
37
|
require_relative 'typesense/stemming_dictionary'
|
38
|
+
require_relative 'typesense/nl_search_models'
|
39
|
+
require_relative 'typesense/nl_search_model'
|
data/typesense.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typesense
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.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: 2025-
|
11
|
+
date: 2025-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.9'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.9'
|
55
55
|
description: Typesense is an open source search engine for building a delightful search
|
56
56
|
experience.
|
57
57
|
email:
|
@@ -99,6 +99,8 @@ files:
|
|
99
99
|
- lib/typesense/keys.rb
|
100
100
|
- lib/typesense/metrics.rb
|
101
101
|
- lib/typesense/multi_search.rb
|
102
|
+
- lib/typesense/nl_search_model.rb
|
103
|
+
- lib/typesense/nl_search_models.rb
|
102
104
|
- lib/typesense/operations.rb
|
103
105
|
- lib/typesense/override.rb
|
104
106
|
- lib/typesense/overrides.rb
|