🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
183 lines
6.6 KiB
TypeScript
Executable File
183 lines
6.6 KiB
TypeScript
Executable File
/// <reference types="node" />
|
|
import { CommandParser } from "@redis/client/dist/lib/client/parser";
|
|
import { RedisArgument, ReplyUnion } from "@redis/client/dist/lib/RESP/types";
|
|
import { RedisVariadicArgument } from "@redis/client/dist/lib/commands/generic-transformers";
|
|
import { GroupByReducers } from "./AGGREGATE";
|
|
/**
|
|
* Text search expression configuration for hybrid search.
|
|
*/
|
|
export interface FtHybridSearchExpression {
|
|
/** Search query string or parameter reference (e.g., "$q") */
|
|
query: RedisArgument;
|
|
/** Scoring algorithm configuration */
|
|
SCORER?: RedisArgument;
|
|
/** Alias for the text search score in results */
|
|
YIELD_SCORE_AS?: RedisArgument;
|
|
}
|
|
/**
|
|
* Vector search method configuration - either KNN or RANGE.
|
|
*/
|
|
export declare const FT_HYBRID_VECTOR_METHOD: {
|
|
/** K-Nearest Neighbors search configuration */
|
|
readonly KNN: "KNN";
|
|
/** Range-based vector search configuration */
|
|
readonly RANGE: "RANGE";
|
|
};
|
|
/** Vector search method type */
|
|
export type FtHybridVectorMethodType = (typeof FT_HYBRID_VECTOR_METHOD)[keyof typeof FT_HYBRID_VECTOR_METHOD];
|
|
interface FtHybridVectorMethodKNN {
|
|
type: (typeof FT_HYBRID_VECTOR_METHOD)["KNN"];
|
|
/** Number of nearest neighbors to find */
|
|
K: number;
|
|
/** Controls the search accuracy vs. speed tradeoff */
|
|
EF_RUNTIME?: number;
|
|
}
|
|
interface FtHybridVectorMethodRange {
|
|
type: (typeof FT_HYBRID_VECTOR_METHOD)["RANGE"];
|
|
/** Maximum distance for matches */
|
|
RADIUS: number;
|
|
/** Provides additional precision control */
|
|
EPSILON?: number;
|
|
}
|
|
/**
|
|
* Vector similarity search expression configuration.
|
|
*/
|
|
export interface FtHybridVectorExpression {
|
|
/** Vector field name (e.g., "@embedding") */
|
|
field: RedisArgument;
|
|
/** Vector parameter reference (e.g., "$v") */
|
|
vector: string;
|
|
/** Search method configuration - KNN or RANGE */
|
|
method?: FtHybridVectorMethodKNN | FtHybridVectorMethodRange;
|
|
/** Pre-filter expression applied before vector search (e.g., "@tag:{foo}") */
|
|
FILTER?: RedisArgument;
|
|
/** Alias for the vector score in results */
|
|
YIELD_SCORE_AS?: RedisArgument;
|
|
}
|
|
/**
|
|
* Score fusion method type constants for combining search results.
|
|
*/
|
|
export declare const FT_HYBRID_COMBINE_METHOD: {
|
|
/** Reciprocal Rank Fusion */
|
|
readonly RRF: "RRF";
|
|
/** Linear combination with ALPHA and BETA weights */
|
|
readonly LINEAR: "LINEAR";
|
|
};
|
|
/** Combine method type */
|
|
export type FtHybridCombineMethodType = (typeof FT_HYBRID_COMBINE_METHOD)[keyof typeof FT_HYBRID_COMBINE_METHOD];
|
|
interface FtHybridCombineMethodRRF {
|
|
type: (typeof FT_HYBRID_COMBINE_METHOD)["RRF"];
|
|
/** RRF constant for score calculation */
|
|
CONSTANT?: number;
|
|
/** Window size for score normalization */
|
|
WINDOW?: number;
|
|
}
|
|
interface FtHybridCombineMethodLinear {
|
|
type: (typeof FT_HYBRID_COMBINE_METHOD)["LINEAR"];
|
|
/** Weight for text search score */
|
|
ALPHA?: number;
|
|
/** Weight for vector search score */
|
|
BETA?: number;
|
|
/** Window size for score normalization */
|
|
WINDOW?: number;
|
|
}
|
|
/**
|
|
* Apply expression for result transformation.
|
|
*/
|
|
export interface FtHybridApply {
|
|
/** Transformation expression to apply */
|
|
expression: RedisArgument;
|
|
/** Alias for the computed value in output */
|
|
AS?: RedisArgument;
|
|
}
|
|
/**
|
|
* Options for the FT.HYBRID command.
|
|
*/
|
|
export interface FtHybridOptions {
|
|
/** Text search expression configuration */
|
|
SEARCH: FtHybridSearchExpression;
|
|
/** Vector similarity search expression configuration */
|
|
VSIM: FtHybridVectorExpression;
|
|
/** Score fusion configuration for combining SEARCH and VSIM results */
|
|
COMBINE?: {
|
|
/** Fusion method: RRF or LINEAR */
|
|
method: FtHybridCombineMethodRRF | FtHybridCombineMethodLinear;
|
|
/** Alias for the combined score in results */
|
|
YIELD_SCORE_AS?: RedisArgument;
|
|
};
|
|
/**
|
|
* Fields to load and return in results (LOAD clause).
|
|
* - Use `"*"` to load all fields from documents
|
|
* - Use a field name or array of field names to load specific fields
|
|
*/
|
|
LOAD?: RedisVariadicArgument;
|
|
/** Group by configuration for aggregation */
|
|
GROUPBY?: {
|
|
/** Fields to group by */
|
|
fields: RedisVariadicArgument;
|
|
/** Reducer(s) to apply to each group */
|
|
REDUCE?: GroupByReducers | Array<GroupByReducers>;
|
|
};
|
|
/** Apply expression(s) for result transformation */
|
|
APPLY?: FtHybridApply | Array<FtHybridApply>;
|
|
/** Sort configuration for results */
|
|
SORTBY?: {
|
|
/** Fields to sort by with optional direction */
|
|
fields: Array<{
|
|
/** Field name to sort by */
|
|
field: RedisArgument;
|
|
/** Sort direction: "ASC" (ascending) or "DESC" (descending) */
|
|
direction?: "ASC" | "DESC";
|
|
}>;
|
|
};
|
|
/** Disable sorting - returns results in arbitrary order */
|
|
NOSORT?: boolean;
|
|
/** Post-filter expression applied after scoring */
|
|
FILTER?: RedisArgument;
|
|
/** Pagination configuration */
|
|
LIMIT?: {
|
|
/** Number of results to skip */
|
|
offset: number | RedisArgument;
|
|
/** Number of results to return */
|
|
count: number | RedisArgument;
|
|
};
|
|
/** Query parameters for parameterized queries */
|
|
PARAMS?: Record<string, string | number | Buffer>;
|
|
/** Query timeout in milliseconds */
|
|
TIMEOUT?: number;
|
|
}
|
|
declare const _default: {
|
|
readonly NOT_KEYED_COMMAND: true;
|
|
readonly IS_READ_ONLY: true;
|
|
/**
|
|
* Performs a hybrid search combining multiple search expressions.
|
|
* Supports multiple SEARCH and VECTOR expressions with various fusion methods.
|
|
*
|
|
* @experimental
|
|
* NOTE: FT.Hybrid is still in experimental state
|
|
* It's behaviour and function signature may change
|
|
*
|
|
* @param parser - The command parser
|
|
* @param index - The index name to search
|
|
* @param options - Hybrid search options including:
|
|
* - SEARCH: Text search expression with optional scoring
|
|
* - VSIM: Vector similarity expression with KNN/RANGE methods
|
|
* - COMBINE: Fusion method (RRF, LINEAR)
|
|
* - Post-processing operations: LOAD, GROUPBY, APPLY, SORTBY, FILTER
|
|
* - Tunable options: LIMIT, PARAMS, TIMEOUT
|
|
*/
|
|
readonly parseCommand: (this: void, parser: CommandParser, index: RedisArgument, options: FtHybridOptions) => void;
|
|
readonly transformReply: {
|
|
readonly 2: (reply: any) => HybridSearchResult;
|
|
readonly 3: () => ReplyUnion;
|
|
};
|
|
readonly unstableResp3: true;
|
|
};
|
|
export default _default;
|
|
export interface HybridSearchResult {
|
|
totalResults: number;
|
|
executionTime: number;
|
|
warnings: string[];
|
|
results: Record<string, any>[];
|
|
}
|
|
//# sourceMappingURL=HYBRID.d.ts.map
|