The type of objects in the data array
The type of the metric raw result
Private ReadonlydataThe array of objects to process
Private ReadonlykeyThe property key to extract for comparison
PrivateextractExtracts string values from the data array using the configured key.
PrivateextractPrivatefinalizeFinalizes the lookup process by normalizing, sorting, and rebuilding results.
The raw metric results
The extracted strings for index mapping
Optionalopt: StructuredDataOptionsAdditional options
PrivateisType guard to check if a value is CmpStrResult & { raw?: R }.
The value to check
PrivateisType guard to check if a value is MetricResultSingle
The value to check
Performs a batch comparison against a query string.
The comparison function
The query string to compare against
Optionalopt: StructuredDataOptionsOptional lookup options
Asynchronously performs a batch comparison against a query string.
The async comparison function
The query string to compare against
Optionalopt: StructuredDataOptionsOptional lookup options
Performs a pairwise comparison against another array of objects.
The type of objects in the other array
The comparison function
The other array of objects
The property key in the other array
Optionalopt: StructuredDataOptionsOptional lookup options
Asynchronously performs a pairwise comparison against another array of objects.
The type of objects in the other array
The async comparison function
The other array of objects
The property key in the other array
Optionalopt: StructuredDataOptionsOptional lookup options
PrivatenormalizeNormalizes metric results to a consistent format.
Attaches original indices for correct mapping after sorting.
Handles both CmpStrResult[] and MetricResultBatch
The raw metric results
PrivateperformPerforms a lookup with a synchronous comparison function.
The comparison function
The extracted strings for index mapping
Optionalopt: StructuredDataOptionsAdditional options
PrivateperformPerforms a lookup with an asynchronous comparison function.
The async comparison function
The extracted strings for index mapping
Optionalopt: StructuredDataOptionsAdditional options
PrivaterebuildRebuilds results with original objects attached. Maps results to source objects using target string matching with duplicate handling. Works correctly even when results are filtered or subset (e.g., from closest/furthest).
The normalized metric results
The source data array for object attachment
The extracted strings array for index mapping
OptionalremoveZero: booleanWhether to remove zero similarity results
OptionalobjectsOnly: booleanReturn only objects without metadata
PrivatesortSorts results in-place by match score. Preserves __idx for tracking original positions.
The results to sort
Optionalsort: string | booleanSort direction (asc, desc, or boolean true=desc)
Staticcreate
The StructuredData class provides factory methods for processing arrays of structured objects with string comparison capabilities.