Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(vdb): add document_id keyword mapping and fix VectorType in elasticsearch-ja adapter (#40400)

Rafli Surya Wijaya385e8662bbfc
diff --git a/api/providers/vdb/vdb-elasticsearch/src/dify_vdb_elasticsearch/elasticsearch_ja_vector.py b/api/providers/vdb/vdb-elasticsearch/src/dify_vdb_elasticsearch/elasticsearch_ja_vector.py
index cff39830f88..49da9db987a 100644
--- a/api/providers/vdb/vdb-elasticsearch/src/dify_vdb_elasticsearch/elasticsearch_ja_vector.py
+++ b/api/providers/vdb/vdb-elasticsearch/src/dify_vdb_elasticsearch/elasticsearch_ja_vector.py
@@ -72,7 +72,10 @@ class ElasticSearchJaVector(ElasticSearchVector):
Field.METADATA_KEY: {
"type": "object",
"properties": {
- "doc_id": {"type": "keyword"} # Map doc_id to keyword type
+ "doc_id": {"type": "keyword"}, # Map doc_id to keyword type
+ "document_id": {
+ "type": "keyword"
+ }, # Map document_id to keyword type; required for document-scoped retrieval
},
},
}
@@ -91,7 +94,7 @@ class ElasticSearchJaVectorFactory(ElasticSearchVectorFactory):
else:
dataset_id = dataset.id
collection_name = Dataset.gen_collection_name_by_id(dataset_id)
- dataset.index_struct = json.dumps(self.gen_index_struct_dict(VectorType.ELASTICSEARCH, collection_name))
+ dataset.index_struct = json.dumps(self.gen_index_struct_dict(VectorType.ELASTICSEARCH_JA, collection_name))
config = current_app.config
return ElasticSearchJaVector(