Elasticsearch修改映射报错:未知设置[index.knn.algo_param.m]
解决Elasticsearch创建索引时
index.knn.algo_param.m未知设置错误 错误原因
你遇到的错误是因为**knn.algo_param系列参数不属于索引级别的设置项**,而是需要定义在knn_vector字段的映射配置中;同时m参数需要是整数类型,不能用字符串"4"。
修正后的创建索引请求
PUT posting { "settings":{ "index":{ "number_of_shards":1, "number_of_replicas":0, "knn": true } }, "mappings":{ "properties":{ "vector":{ "type":"knn_vector", "dimension":384, "algo_param":{ "ef_search":40, "ef_construction":40, "m":4 } }, "title":{ "type":"text", "fields":{ "keyword":{ "type":"keyword", "index":false } } }, "company":{ "type":"keyword", "index":false }, "location":{ "type":"keyword", "index":false }, "salary":{ "type":"keyword", "index":false }, "job_description":{ "type":"keyword", "index":false } } } }
关键调整点
- 将
knn.algo_param的配置从索引settings移到vector字段的映射下,因为这些参数是HNSW算法针对具体向量字段的配置项 - 把
m:"4"改为m:4,确保参数是整数类型 - 将顶层的
"knn":true移到index设置内,符合Elasticsearch的配置规范
内容的提问来源于stack exchange,提问作者utkarsh404
相关产品推荐
相关产品推荐

