@yoch/frozenminisearch 1.2.2 → 1.2.4
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/CHANGELOG.md +27 -0
- package/README.md +43 -98
- package/dist/cjs/index.cjs +2495 -2272
- package/dist/es/index.d.ts +44 -16
- package/dist/es/index.js +2492 -2273
- package/package.json +3 -1
package/dist/es/index.d.ts
CHANGED
|
@@ -247,9 +247,48 @@ type VacuumConditions = {
|
|
|
247
247
|
*/
|
|
248
248
|
type AutoVacuumOptions = VacuumOptions & VacuumConditions;
|
|
249
249
|
|
|
250
|
+
/**
|
|
251
|
+
* Runtime stored fields. Single store field → one column (no per-doc Record at rest).
|
|
252
|
+
* Wire format stays row JSON; encode/decode can skip intermediate row arrays when layout is known.
|
|
253
|
+
*/
|
|
254
|
+
type StoredFieldsLayout = {
|
|
255
|
+
kind: 'none';
|
|
256
|
+
} | {
|
|
257
|
+
kind: 'single';
|
|
258
|
+
field: string;
|
|
259
|
+
values: unknown[];
|
|
260
|
+
} | {
|
|
261
|
+
kind: 'multi';
|
|
262
|
+
rows: (Record<string, unknown> | undefined)[];
|
|
263
|
+
};
|
|
264
|
+
|
|
250
265
|
declare const OR: LowercaseCombinationOperator;
|
|
251
266
|
declare const AND: LowercaseCombinationOperator;
|
|
252
267
|
declare const AND_NOT: LowercaseCombinationOperator;
|
|
268
|
+
interface RawResultValue {
|
|
269
|
+
score: number;
|
|
270
|
+
terms: string[];
|
|
271
|
+
match: MatchInfo;
|
|
272
|
+
}
|
|
273
|
+
type RawResult = Map<number, RawResultValue>;
|
|
274
|
+
interface FinalizeSearchParams {
|
|
275
|
+
rawResults: RawResult;
|
|
276
|
+
getExternalId: (docId: number) => unknown;
|
|
277
|
+
getStoredFields?: (docId: number) => Record<string, unknown> | undefined;
|
|
278
|
+
/** When set, copies stored fields in place (no per-doc row allocation for single-column layouts). */
|
|
279
|
+
storedFieldsLayout?: StoredFieldsLayout;
|
|
280
|
+
filter?: (result: SearchResult) => boolean;
|
|
281
|
+
skipSort?: boolean;
|
|
282
|
+
}
|
|
283
|
+
/** Merge search options, apply wildcard skipSort, then {@link finalizeSearchResults}. */
|
|
284
|
+
declare function finalizeRawSearchResults(rawResults: RawResult, query: Query, searchOptions: SearchOptions, globalSearchOptions: SearchOptionsWithDefaults, getExternalId: (docId: number) => unknown, getStoredFields?: (docId: number) => Record<string, unknown> | undefined, storedFieldsLayout?: StoredFieldsLayout): SearchResult[];
|
|
285
|
+
declare function finalizeSearchResults(params: FinalizeSearchParams): SearchResult[];
|
|
286
|
+
|
|
287
|
+
type SuggestionHit = Pick<SearchResult, 'score' | 'terms'>;
|
|
288
|
+
/** Aggregate search hits into ranked phrase suggestions. */
|
|
289
|
+
declare function suggestFromSearchResults(hits: Iterable<SuggestionHit>): Suggestion[];
|
|
290
|
+
/** Build suggestions from raw search hits without materializing full public results. */
|
|
291
|
+
declare function suggestFromRawResults(rawResults: RawResult): Suggestion[];
|
|
253
292
|
|
|
254
293
|
/**
|
|
255
294
|
* Smallest unsigned typed array that can hold the structure's indices. Widths
|
|
@@ -425,21 +464,6 @@ interface FrozenPostingsLayout {
|
|
|
425
464
|
/** Adaptive-width unsigned column (1/2/4 bytes per element) for field lengths and packed radix columns. */
|
|
426
465
|
type FieldLengthArray = PackedIndexArray;
|
|
427
466
|
|
|
428
|
-
/**
|
|
429
|
-
* Runtime stored fields. Single store field → one column (no per-doc Record at rest).
|
|
430
|
-
* Wire format stays row JSON; encode/decode can skip intermediate row arrays when layout is known.
|
|
431
|
-
*/
|
|
432
|
-
type StoredFieldsLayout = {
|
|
433
|
-
kind: 'none';
|
|
434
|
-
} | {
|
|
435
|
-
kind: 'single';
|
|
436
|
-
field: string;
|
|
437
|
-
values: unknown[];
|
|
438
|
-
} | {
|
|
439
|
-
kind: 'multi';
|
|
440
|
-
rows: (Record<string, unknown> | undefined)[];
|
|
441
|
-
};
|
|
442
|
-
|
|
443
467
|
interface FrozenMemoryBreakdown {
|
|
444
468
|
termCount: number;
|
|
445
469
|
documentCount: number;
|
|
@@ -609,6 +633,10 @@ declare class FrozenMiniSearch<T = any> {
|
|
|
609
633
|
has(id: unknown): boolean;
|
|
610
634
|
getStoredFields(id: unknown): Record<string, unknown> | undefined;
|
|
611
635
|
search(query: Query, searchOptions?: SearchOptions): SearchResult[];
|
|
636
|
+
/**
|
|
637
|
+
* Without a `filter`, aggregates suggestions from raw query hits (no full result materialization).
|
|
638
|
+
* With a `filter`, uses {@link search} so stored fields are available to the predicate.
|
|
639
|
+
*/
|
|
612
640
|
autoSuggest(queryString: string, options?: SearchOptions): Suggestion[];
|
|
613
641
|
/** Serialize this index as a frozen binary snapshot (synchronous). */
|
|
614
642
|
saveBinarySync(saveOptions?: SaveBinaryOptions): Buffer;
|
|
@@ -657,5 +685,5 @@ declare class FrozenMiniSearch<T = any> {
|
|
|
657
685
|
private executeQuery;
|
|
658
686
|
}
|
|
659
687
|
|
|
660
|
-
export { AND, AND_NOT, FrozenIndexBuilder, FrozenMiniSearch, OR, assembleFrozen, buildFrozenFromDocuments, createFrozenIndexBuilder, FrozenMiniSearch as default, freezeFrozenIndexBuilder, frozenMemoryBreakdown };
|
|
688
|
+
export { AND, AND_NOT, FrozenIndexBuilder, FrozenMiniSearch, OR, assembleFrozen, buildFrozenFromDocuments, createFrozenIndexBuilder, FrozenMiniSearch as default, finalizeRawSearchResults, finalizeSearchResults, freezeFrozenIndexBuilder, frozenMemoryBreakdown, suggestFromRawResults, suggestFromSearchResults };
|
|
661
689
|
export type { BM25Params, BinaryCompression, CombinationOperator, FrozenAssembleParams, FrozenIndexBuilderHints, FrozenMemoryBreakdown, LogLevel, LowercaseCombinationOperator, MatchInfo, MiniSearchSnapshot, Options, Query, QueryCombination, SaveBinaryOptions, SearchOptions, SearchResult, SerializedIndexEntry, Suggestion, Wildcard };
|