Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(mappings): support any embedding dimension on Elasticsearch (#20368)

qinling021002569aee9d74
diff --git a/conf/mapping.json b/conf/mapping.json
index 1d8a8e65a5..447f3339db 100644
--- a/conf/mapping.json
+++ b/conf/mapping.json
@@ -159,45 +159,11 @@
},
{
"dense_vector": {
- "match": "*_512_vec",
+ "match": "q_*_vec",
"mapping": {
"type": "dense_vector",
"index": true,
- "similarity": "cosine",
- "dims": 512
- }
- }
- },
- {
- "dense_vector": {
- "match": "*_768_vec",
- "mapping": {
- "type": "dense_vector",
- "index": true,
- "similarity": "cosine",
- "dims": 768
- }
- }
- },
- {
- "dense_vector": {
- "match": "*_1024_vec",
- "mapping": {
- "type": "dense_vector",
- "index": true,
- "similarity": "cosine",
- "dims": 1024
- }
- }
- },
- {
- "dense_vector": {
- "match": "*_1536_vec",
- "mapping": {
- "type": "dense_vector",
- "index": true,
- "similarity": "cosine",
- "dims": 1536
+ "similarity": "cosine"
}
}
},
diff --git a/internal/service/nlp/datasetnav_test.go b/internal/service/nlp/datasetnav_test.go
index f900aa272b..56e03bef5c 100644
--- a/internal/service/nlp/datasetnav_test.go
+++ b/internal/service/nlp/datasetnav_test.go
@@ -288,13 +288,9 @@ func (stubNavEmbedder) Encode(_ context.Context, _ string, texts []string) ([][]
out := make([][]float32, len(texts))
for i, t := range texts {
// The ES document index template (mapping.json, the ragflow_*
- // dynamic_templates) maps q_<dim>_vec to a dense_vector field only for
- // the standard embedding dimensions 512/768/1024/1536. The integration
- // test runs NavService.Search as a real knn query against that index,
- // so the synthetic vector must use one of those dimensions — otherwise
- // ES dynamically maps q_<dim>_vec as a plain float array and the knn
- // query fails with "[knn] queries are only supported on [dense_vector]
- // fields". 1024 is the canonical RAGFlow embedding size.
+ // dynamic_templates) maps any q_<dim>_vec field to dense_vector, so the
+ // synthetic vector may use any dimension. 1024 is the canonical
+ // RAGFlow embedding size.
dim := 1024
v := make([]float32, dim)
for d := 0; d < dim; d++ {