@fondation-io/fast-db-batch-search-client
Version:
TypeScript client for Fast-DB batch search API with support for fuzzy search
84 lines • 3.11 kB
TypeScript
import { SearchResult, BatchSearchOptions, GroupedResults, JoinSearchParams } from './types';
/**
* Client for Fast-DB Batch Search API
*/
export declare class BatchSearchClient {
private axios;
private includeMetrics;
constructor(options?: BatchSearchOptions);
/**
* Execute a batch search query
* @param table The table/collection to search in
* @param nodeField The field containing node information
* @param nodeQuery The node to search for
* @param targetField The field containing target information
* @param targetQueries Array of target queries to search for
* @param projection Fields to return in results
* @param fuzzy Whether to use fuzzy search (default: true)
* @param resultsPerQuery Maximum results per target query (default: 10)
*/
batchSearch(table: string, nodeField: string, nodeQuery: string, targetField: string, targetQueries: string[], projection?: string[], fuzzy?: boolean, resultsPerQuery?: number): Promise<{
results: SearchResult[];
grouped: GroupedResults;
metrics?: Record<string, unknown>;
totalResults: number;
}>;
/**
* Convert DataFrame response to array of objects
*/
private dataFrameToObjects;
/**
* Group results by search_group_hash
*/
private groupResultsByHash;
/**
* Execute a batch search query with joins across multiple tables
* @param params Join search parameters
*/
batchSearchWithJoins(params: JoinSearchParams): Promise<{
results: SearchResult[];
grouped: GroupedResults;
metrics?: Record<string, unknown>;
totalResults: number;
}>;
/**
* Convenience method for searching book series by author
* @deprecated Use searchRelatedItems instead
*/
searchBookSeries(author: string, seriesTitles: string[], maxPerTitle?: number): Promise<{
results: SearchResult[];
grouped: GroupedResults;
metrics?: Record<string, unknown>;
totalResults: number;
}>;
/**
* Generic method for searching related items by a common node
*/
searchRelatedItems(table: string, nodeField: string, nodeValue: string, targetField: string, targetValues: string[], projection?: string[], maxPerTarget?: number): Promise<{
results: SearchResult[];
grouped: GroupedResults;
metrics?: Record<string, unknown>;
totalResults: number;
}>;
/**
* Convenience method for searching albums by artist using joins
*/
searchAlbumsByArtist(artist: string, albumTitles: string[], maxPerAlbum?: number): Promise<{
results: SearchResult[];
grouped: GroupedResults;
metrics?: Record<string, unknown>;
totalResults: number;
}>;
/**
* Get search statistics from grouped results
*/
getSearchStats(grouped: GroupedResults): {
totalGroups: number;
groupSizes: {
[hash: string]: number;
};
averageGroupSize: number;
emptyGroups: number;
};
}
//# sourceMappingURL=client.d.ts.map