openGauss vector store ignores document_ids_filter, so metadata filtering returns chunks from other documents

Open
#46,989 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Harshil26202 is already working on this.

Since Nov 23, 2026.

  • #46990 by @Harshil26202 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, databases

Research direction

The filter is dropped in the openGauss vector store provider: OpenGauss.search_by_vector and OpenGauss.search_by_full_text accept document_ids_filter but never apply it, while pgvector's provider does. Start by reading the openGauss provider under api/core/rag/datasource/vdb/ alongside its pgvector counterpart, then look at how DatasetRetrieval builds the filter. Reproduce with the two-document example in the report and confirm filtered searches return only matching chunks; note that a fix PR (#46990) is already open.

Written by the indexing model from the issue text.

Description

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 (580416d, api 1.20.0)

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce
  1. Set VECTOR_STORE=opengauss.
  2. Create a knowledge base with two documents and give them different metadata, for example category = a and category = b.
  3. In a Knowledge Retrieval node, add the metadata filter category is a and query a phrase that appears in both documents.

The same thing at the provider level, against opengauss/opengauss:7.0.0-RC1 (the image in docker-compose):

vector = OpenGauss(collection_name="test", config=config)
vector.create(texts=[doc_a, doc_b], embeddings=[embedding, embedding])  # different metadata["document_id"]
vector.search_by_vector(embedding, top_k=10, document_ids_filter=[doc_a.metadata["document_id"]])
vector.search_by_full_text("test_text", top_k=10, document_ids_filter=[doc_a.metadata["document_id"]])
✔️ Expected Behavior

Only chunks of the documents that match the filter are returned, as with pgvector.

❌ Actual Behavior

Chunks of the other document are returned too. DatasetRetrieval passes the ids of the matching documents as document_ids_filter, but OpenGauss.search_by_vector and OpenGauss.search_by_full_text never read that argument, so the filter has no effect on openGauss. In a check with 4 documents of 3 chunks each, filtering on 2 documents returned 10 chunks from all 4, and a full-text search filtered on one document returned all 12 matches.

I have a fix with tests and will open a PR.

Dominant language
Python
Stars
162k
Forks
25.6k
Avg merge
15h 9m
Merged PRs (30d)
606

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from langgenius/dify

All issues in langgenius/dify

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.