Milvus search metadata filter bug #12237

Closed
opened 2026-02-21 19:06:30 -05:00 by yindo · 2 comments
Owner

Originally created by @JulyMood on GitHub (Mar 27, 2025).

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.3

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

Image

filter = f'metadata["document_id"] in ({document_ids})'
Syntax error, Restore to
filter = f'metadata["document_id"] in [{document_ids}]'

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @JulyMood on GitHub (Mar 27, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.3 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce ![Image](https://github.com/user-attachments/assets/c763925d-d236-4442-87bc-f1f4c7d68931) filter = f'metadata["document_id"] in ({document_ids})' Syntax error, Restore to filter = f'metadata["document_id"] in [{document_ids}]' ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:06:30 -05:00
yindo closed this issue 2026-02-21 19:06:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 27, 2025):

Hello @JulyMood! I'm here to help you with any bugs, questions, or contributions you have for the project. Let me know how I can assist you!

To address the syntax error in the search_by_full_text method when constructing a filter string for metadata-based document ID filtering in Milvus, ensure that the filter string is correctly formatted. The correct format should be:

if document_ids_filter:
    document_ids = ", ".join(f"'{id}'" for id in document_ids_filter)
    filter = f'metadata["document_id"] in [{document_ids}]'

This code constructs a filter string that checks if the document_id in the metadata is within the list of document_ids_filter. Make sure that document_ids_filter is a list of strings and that the Milvus server supports this filter syntax [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 27, 2025): <!-- Greeting --> Hello @JulyMood! I'm here to help you with any bugs, questions, or contributions you have for the project. Let me know how I can assist you! <!-- Answer --> To address the syntax error in the `search_by_full_text` method when constructing a filter string for metadata-based document ID filtering in Milvus, ensure that the filter string is correctly formatted. The correct format should be: ```python if document_ids_filter: document_ids = ", ".join(f"'{id}'" for id in document_ids_filter) filter = f'metadata["document_id"] in [{document_ids}]' ``` This code constructs a filter string that checks if the `document_id` in the metadata is within the list of `document_ids_filter`. Make sure that `document_ids_filter` is a list of strings and that the Milvus server supports this filter syntax <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/rag/datasource/vdb/milvus/milvus_vector.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/cb62114e-b5b7-445a-902c-2d14f909c5ae?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/cb62114e-b5b7-445a-902c-2d14f909c5ae?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/cb62114e-b5b7-445a-902c-2d14f909c5ae?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/cb62114e-b5b7-445a-902c-2d14f909c5ae?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cb62114e-b5b7-445a-902c-2d14f909c5ae?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/cb62114e-b5b7-445a-902c-2d14f909c5ae?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cb62114e-b5b7-445a-902c-2d14f909c5ae?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Mar 27, 2025):

Will be fixed in ext version.

@crazywoola commented on GitHub (Mar 27, 2025): Will be fixed in ext version.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12237