search
Once an index is created, you can perform multiple searches using the same index:
Type Definition
Section titled “Type Definition”async function search(index: StaticSeekIndex, query: string): Promise<SearchResult[] | StaticSeekError>;Parameters
Section titled “Parameters”index: AStaticSeekIndexobject that represents the index to be searched.query: A string representing the search query.
Return Value
Section titled “Return Value”The function returns either a SearchResult[] object described in Query Result or StaticSeekError if query fails.
import { createIndex, LinearIndex, search, StaticSeekError } from "staticseek";
const index = createIndex(LinearIndex, array_of_articles);if (index instanceof StaticSeekError) throw index;
const result = await search(index, "search word");if (result instanceof StaticSeekError) throw result;// Process the search results