search-engine-for-typesense 30.1.6.14 → 30.1.6.16
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/lib/search_engine/schema.rb +54 -5
- data/lib/search_engine/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4f73039b28d08542d582f09279574bf2d982218434259e17e2ef341a98959cf
|
|
4
|
+
data.tar.gz: 1c4b811b429fd29d13b878a1cc9e292ca268e79f8746c1632ac29810bf82c0c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: afeca782edfa298e76b459e6ec7307d2b896a6a77987d70e3525602a2f052e2556df973d204f6be4ec38ef562e0b90ef0ce679c737c715ae278b783c014eab30
|
|
7
|
+
data.tar.gz: b7eb1fb839c37de2999bc1bdbcc78598aaa3b151961ae04fd8f3964d84207550f562b8d72840d03e2a97d0ca6ffc109ec9d34ea7608f8f6aea88c56c5e866c53
|
data/lib/search_engine/schema.rb
CHANGED
|
@@ -1259,6 +1259,12 @@ module SearchEngine
|
|
|
1259
1259
|
existing = client.retrieve_collection_schema(logical_name)
|
|
1260
1260
|
return unless existing
|
|
1261
1261
|
|
|
1262
|
+
# Typesense GET /collections/:name transparently resolves aliases.
|
|
1263
|
+
# If the returned schema's name differs from the logical name, no bare
|
|
1264
|
+
# collection exists — the alias was resolved to its physical target.
|
|
1265
|
+
schema_name = (existing[:name] || existing['name']).to_s
|
|
1266
|
+
return unless schema_name == logical_name
|
|
1267
|
+
|
|
1262
1268
|
client.delete_collection(logical_name, timeout_ms: 60_000)
|
|
1263
1269
|
return unless defined?(ActiveSupport::Notifications)
|
|
1264
1270
|
|
|
@@ -1278,12 +1284,55 @@ module SearchEngine
|
|
|
1278
1284
|
# @raise [ArgumentError] if schema cannot be retrieved
|
|
1279
1285
|
def retrieve_referenced_schema(logical_coll, physical_coll, client)
|
|
1280
1286
|
referenced_schema = client.retrieve_collection_schema(physical_coll)
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1287
|
+
return referenced_schema unless referenced_schema.nil?
|
|
1288
|
+
|
|
1289
|
+
repaired_physical = recover_reference_alias_target(
|
|
1290
|
+
logical_coll,
|
|
1291
|
+
missing_physical: physical_coll,
|
|
1292
|
+
client: client
|
|
1293
|
+
)
|
|
1294
|
+
unless repaired_physical.nil?
|
|
1295
|
+
referenced_schema = client.retrieve_collection_schema(repaired_physical)
|
|
1296
|
+
return referenced_schema unless referenced_schema.nil?
|
|
1285
1297
|
end
|
|
1286
|
-
|
|
1298
|
+
|
|
1299
|
+
raise ArgumentError,
|
|
1300
|
+
"Referenced collection '#{logical_coll}' (physical: '#{physical_coll}') " \
|
|
1301
|
+
'schema could not be retrieved'
|
|
1302
|
+
end
|
|
1303
|
+
|
|
1304
|
+
# Best-effort repair when a reference alias points to a missing physical
|
|
1305
|
+
# collection. Repoints the logical alias to the newest retained physical.
|
|
1306
|
+
# Returns nil if no safe repair candidate exists.
|
|
1307
|
+
#
|
|
1308
|
+
# @param logical_coll [String]
|
|
1309
|
+
# @param missing_physical [String]
|
|
1310
|
+
# @param client [SearchEngine::Client]
|
|
1311
|
+
# @return [String, nil]
|
|
1312
|
+
def recover_reference_alias_target(logical_coll, missing_physical:, client:)
|
|
1313
|
+
logical_name = logical_coll.to_s
|
|
1314
|
+
return nil if logical_name.strip.empty?
|
|
1315
|
+
|
|
1316
|
+
candidates = list_physicals(logical_name, client: client)
|
|
1317
|
+
return nil if candidates.empty?
|
|
1318
|
+
|
|
1319
|
+
repaired_physical = order_physicals_desc(logical_name, candidates).first
|
|
1320
|
+
return nil if repaired_physical.nil? || repaired_physical.to_s.strip.empty?
|
|
1321
|
+
return nil if repaired_physical.to_s == missing_physical.to_s
|
|
1322
|
+
|
|
1323
|
+
client.upsert_alias(logical_name, repaired_physical)
|
|
1324
|
+
if defined?(ActiveSupport::Notifications)
|
|
1325
|
+
SearchEngine::Instrumentation.instrument(
|
|
1326
|
+
'search_engine.schema.reference_alias_repaired',
|
|
1327
|
+
logical: logical_name,
|
|
1328
|
+
stale_physical: missing_physical.to_s,
|
|
1329
|
+
repaired_physical: repaired_physical
|
|
1330
|
+
) {}
|
|
1331
|
+
end
|
|
1332
|
+
|
|
1333
|
+
repaired_physical
|
|
1334
|
+
rescue StandardError
|
|
1335
|
+
nil
|
|
1287
1336
|
end
|
|
1288
1337
|
|
|
1289
1338
|
# Build a detailed error message when a referenced field is not found.
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: search-engine-for-typesense
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 30.1.6.
|
|
4
|
+
version: 30.1.6.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nikita Shkoda
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|