IRIS vector search ignores document_ids_filter, so metadata filtering returns chunks from other documents

Open
#46,991 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Harshil26202 is already working on this.

Since Nov 23, 2026.

  • #46992 by @Harshil26202 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
32/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, sql
Domain
databases, search

Research direction

Start in the IRIS vector store provider at IrisVector.search_by_vector, where the SELECT TOP {top_k} ... ORDER BY score DESC query is assembled without document_ids_filter; compare it with the two full-text paths (iFind and LIKE) that already add JSON_VALUE(meta, '$.document_id') IN (...). Read the existing provider unit tests for the full-text filter to mirror their setup, then confirm both a filtered and unfiltered semantic search return only the expected chunks. Done means search_by_vector respects document_ids_filter with tests covering the filtered case. Note a fix PR (#46992) 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=iris.
  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 using semantic search, add the metadata filter category is a and query a phrase that appears in both documents.

At the provider level:

vector.search_by_vector(embedding, 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 IrisVector.search_by_full_text already does.

❌ Actual Behavior

IrisVector.search_by_vector never reads document_ids_filter: its query is SELECT TOP {top_k} ... ORDER BY score DESC over the whole table, so the metadata filter has no effect on semantic search with IRIS and chunks from other documents are returned. Both full-text paths (iFind and LIKE) already add JSON_VALUE(meta, '$.document_id') IN (...).

I have a fix with unit 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.