Skip to content

IndexSearchResult

A lightweight search result containing only index and score (no item string).

Use this when you maintain your own data array and only need the index to look up the original item. Avoids String cloning overhead.

Property Type Description
index number The index of the item in the original input array.
matchType? MatchType How the query matched this item (Exact, Prefix, Contains, or Fuzzy). Only present when includePositions is set to true in SearchOptions. Derived from positions at zero additional cost.
positions number[] Indices of the matched characters of the item, in ascending order. An ASCII item is counted by character; any other item by grapheme cluster (a user-perceived character, such as an emoji with its modifiers or a letter with its combining marks), so these are not UTF-16 string offsets. highlight() and highlightRanges() convert them. Empty unless includePositions is set to true in SearchOptions.
score number The match score normalized to 0.0-1.0 range (1.0 is a perfect match).