Skip to content

search

Once an index is created, you can perform multiple searches using the same index:

async function search(index: StaticSeekIndex, query: string): Promise<SearchResult[] | StaticSeekError>;
  • index: A StaticSeekIndex object that represents the index to be searched.
  • query: A string representing the search query.

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