Skip to content

search

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

Type Definition

async function search(index: StaticSeekIndex, query: string): Promise<SearchResult[] | StaticSeekError>;

Parameters

  • index: A StaticSeekIndex object that represents the index to be searched.
  • query: A string representing the search query.

Return Value

The function returns either a SearchResult[] object described in Query Result or StaticSeekError if query fails.

Usage

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