interface IndexConfig {
    createAllMetricIndexes?: boolean;
    dims: number;
    distanceMetric?: DistanceMetric;
    embed: Embeddings | EmbeddingsFunc;
    fields?: string[];
    hnsw?: HNSWConfig;
    indexType?: VectorIndexType;
    ivfflat?: IVFFlatConfig;
}

属性

createAllMetricIndexes?: boolean

是否为所有距离度量创建索引。如果为 false,则仅为指定的 distanceMetric 创建索引。

默认值

false
dims: number

嵌入向量中的维度数。

distanceMetric?: DistanceMetric

用于向量相似度的距离度量。

默认值

'cosine'

用于从文本生成嵌入的嵌入函数。可以是 LangChain Embeddings 实例或一个函数。

fields?: string[]

用于提取文本以生成嵌入的字段。使用 JSON 路径语法。默认为 ["$"](整个文档)。

hnsw?: HNSWConfig

HNSW 特定的配置参数。仅在 indexType 为 'hnsw' 时使用。

indexType?: VectorIndexType

要使用的向量索引类型。

  • 'hnsw':分层可导航小世界(Hierarchical Navigable Small World)(最适合大多数用例)
  • 'ivfflat':带平面压缩的倒排文件(Inverted File with Flat compression)(适用于大型数据集)

默认值

'hnsw'
ivfflat?: IVFFlatConfig

IVFFlat 特定的配置参数。仅在 indexType 为 'ivfflat' 时使用。