OpenSearch: delete_by_metadata_field never deletes anything, so edited or deleted annotations stay in the annotation index
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start in api/providers/vdb/vdb-opensearch/src/dify_vdb_opensearch/opensearch_vector.py, where delete_by_metadata_field, get_ids_by_metadata_field and delete_by_ids are defined, and check create_collection's field mapping for app_id and annotation_id. Trace the callers in update_annotation_to_index_task, delete_annotation_index_task and enable_annotation_reply_task. Done means deleting by annotation_id or app_id removes the matching documents, and unit tests cover it. A linked pull request already exists, so coordinate with it before starting.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is only for bug report, if you would like to ask a question, please head to Discussions.
- I have searched for existing issues search for existing issues, including closed ones.
- I confirm that I am using English to submit this report, otherwise it will be closed.
- 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- Please do not modify this template :) and fill in all the required fields.
Dify version
main (8985a46)
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
With VECTOR_STORE=opensearch:
- Enable annotation reply on a chat app and add an annotation.
- Edit the annotation's question, or delete the annotation.
- Ask the old question again.
The annotation tasks remove the old vector with vector.delete_by_metadata_field("annotation_id", annotation_id) (update_annotation_to_index_task, delete_annotation_index_task) and vector.delete_by_metadata_field("app_id", app_id) (enable_annotation_reply_task).
✔️ Expected Behavior
The old annotation vector is removed, so the edited or deleted annotation no longer answers the old question.
❌ Actual Behavior
Nothing is deleted. The old vector stays in the OpenSearch index, so annotation reply keeps answering with the old or deleted annotation, and re-enabling annotation reply adds duplicates. For annotation_id and app_id this happens silently; for keyword fields the only trace is a Document with metadata doc_id ... not found for deletion warning per hit.
In api/providers/vdb/vdb-opensearch/src/dify_vdb_opensearch/opensearch_vector.py there are three problems:
delete_by_metadata_fieldpasses the result ofget_ids_by_metadata_fieldtodelete_by_ids. Those are OpenSearch_ids (uuid4().hex, set inadd_texts), butdelete_by_idstreats its argument as metadatadoc_ids and looks each one up again with ametadata.doc_idterm query. No document has an OpenSearch_idas itsdoc_id, so nothing is found and nothing is deleted. This affects every key, includingdocument_id.get_ids_by_metadata_fielduses{"term": {"metadata.<key>": value}}.create_collectiononly mapsdoc_idanddocument_idas keyword.app_idandannotation_idget the dynamic mapping (analyzed text plus a.keywordsubfield), and a term query for a whole UUID never matches the analyzed tokens of a text field.- The search has no
size, so it returns at most 10 hits.
The Elasticsearch backend has a similar problem with a different cause (match instead of term), reported in #46995. This one is separate: it is the OpenSearch backend, and the _id/doc_id mix-up in (1) is specific to it.
I have a fix with unit tests and will open a PR.
- Lingua principale
- Python
- Stelle
- 162k
- Fork
- 25.6k
- Merge medio
- 15h 9m
- PR unite (30g)
- 606
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di langgenius/dify
-
OpenSearch: text_exists() queries OpenSearch _id instead of metadata.doc_id, so it always returns False for indexed chunksForse già presa @SanemIzci l’ha presa 1 giorno fa. Aperta🐞 bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
langgenius/dify#47109 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Log only execution identifiers when a workflow worker starts a runForse già presa @kinglegendzzh l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
langgenius/dify#47094 · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Node.js SDK declares a response body for 204 conversation deletionForse già presa @Wang-Zephyr l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
langgenius/dify#46883 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Provider IDs with a trailing newline are silently accepted and propagatedForse già presa @Batianxieshen1 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
langgenius/dify#46875 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Agent Python SDK polling rejects function-tool results that SSE acceptsForse già presa @EndlessRoad-max l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
langgenius/dify#46868 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di langgenius/dify
Issue simili
-
app: scripts status: backlog type: housekeeping
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
netbox-community/netbox-scripts#239 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
LmeSzinc/AzurLaneAutoScript#6194 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
micronaut-projects/micronaut-core#14585 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
langgenius/graphon#443 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno