@kubun/store-graph 0.14.0 → 0.14.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.
- package/lib/api.js +8 -4
- package/lib/tables.d.ts +1 -1
- package/package.json +3 -3
package/lib/api.js
CHANGED
|
@@ -989,12 +989,16 @@ export function createGraphStore(db, adapter) {
|
|
|
989
989
|
throw new SearchNotEnabledError(modelID);
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
|
+
const offset = params.offset ?? 0;
|
|
993
|
+
// Fetch enough from each model to cover the full [0, offset+first) window
|
|
994
|
+
// before the cross-model merge; the final slice trims to the page.
|
|
995
|
+
const perModelLimit = params.first != null ? offset + params.first : undefined;
|
|
992
996
|
const allResults = [];
|
|
993
997
|
for (const modelID of params.modelIDs){
|
|
994
998
|
const hits = await adapter.searchIndex(db, {
|
|
995
999
|
query: params.query,
|
|
996
1000
|
modelID,
|
|
997
|
-
limit:
|
|
1001
|
+
limit: perModelLimit ?? 50
|
|
998
1002
|
});
|
|
999
1003
|
for (const hit of hits){
|
|
1000
1004
|
allResults.push({
|
|
@@ -1005,9 +1009,9 @@ export function createGraphStore(db, adapter) {
|
|
|
1005
1009
|
}
|
|
1006
1010
|
}
|
|
1007
1011
|
// Sort by absolute rank descending (SQLite bm25 returns negative, PG ts_rank positive)
|
|
1008
|
-
allResults.sort((a, b)=>Math.abs(b.rank) - Math.abs(a.rank));
|
|
1009
|
-
if (params.first) {
|
|
1010
|
-
return allResults.slice(
|
|
1012
|
+
allResults.sort((a, b)=>Math.abs(b.rank) - Math.abs(a.rank) || a.documentID.localeCompare(b.documentID));
|
|
1013
|
+
if (params.first != null) {
|
|
1014
|
+
return allResults.slice(offset, offset + params.first);
|
|
1011
1015
|
}
|
|
1012
1016
|
return allResults;
|
|
1013
1017
|
},
|
package/lib/tables.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/store-graph",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@kubun/db": "^0.14.0",
|
|
19
|
-
"@kubun/db-adapter": "^0.14.
|
|
19
|
+
"@kubun/db-adapter": "^0.14.1",
|
|
20
20
|
"@kubun/id": "^0.14.0",
|
|
21
|
-
"@kubun/protocol": "^0.14.
|
|
21
|
+
"@kubun/protocol": "^0.14.1",
|
|
22
22
|
"@sozai/codec": "^0.4.0",
|
|
23
23
|
"kysely": "^0.29.5"
|
|
24
24
|
},
|