📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

简而言之,当使用Elasticsearch的hnsw字段类型但没有配置必需的[ef_construction]字段时,就会出现此错误。hnsw字段类型用于最近邻搜索,其配置需要特定的参数。要解决此问题,您需要在索引映射中指定[ef_construction]字段。该字段控制索引构建的速度和准确性。您还可以检查您的Elasticsearch版本,因为不同版本对hnsw字段类型的配置可能有不同的要求。

日志上下文 #

日志"[index_options] of type [hnsw] requires field [ef_construction] to be configured"的类名是 DenseVectorFieldMapper.java. 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入背景的人参考:

    Object efConstructionNode = indexOptionsMap.remove("ef_construction");
    if (mNode == null) {
        throw new MapperParsingException("[index_options] of type [hnsw] requires field [m] to be configured");
    }
    if (efConstructionNode == null) {
        throw new MapperParsingException("[index_options] of type [hnsw] requires field [ef_construction] to be configured");
    }
    int m = XContentMapValues.nodeIntegerValue(mNode);
    int efConstruction = XContentMapValues.nodeIntegerValue(efConstructionNode);
    MappingParser.checkNoRemainingFields(fieldName; indexOptionsMap);
    return new HnswIndexOptions(m; efConstruction);