mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-08 08:07:21 +08:00
## Summary - normalize string items for list-valued metadata filters in `meta_filter` - fix `in` / `not in` case asymmetry when document metadata is lowercased but filter list values are not - add regression tests that cover the original issue scenario using uppercase list values ## Validation - `PYTHONPATH=external/ragflow pytest external/ragflow/test/unit_test/common/test_metadata_filter_operators.py -q` ## Notes - I commented on #14389 before opening this PR to claim the issue. - The new tests use `value=["F2", "F11"]` so they fail on the old implementation and pass with this fix. - This also benefits other non-comparison operators that flow through the same normalization path. Co-authored-by: copizza <copizza@users.noreply.github.com> Co-authored-by: Wang Qi <wangq8@outlook.com>
This commit is contained in:
@ -33,6 +33,20 @@ def test_not_in_operator():
|
||||
assert meta_filter(metas, filters) == ["doc3"]
|
||||
|
||||
|
||||
def test_in_operator_with_list_value_is_case_insensitive():
|
||||
metas = {"product": {"F2": ["doc1"], "F11": ["doc2"], "G1": ["doc3"]}}
|
||||
filters = [{"key": "product", "op": "in", "value": ["F2", "F11"]}]
|
||||
|
||||
assert set(meta_filter(metas, filters)) == {"doc1", "doc2"}
|
||||
|
||||
|
||||
def test_not_in_operator_with_list_value_is_case_insensitive():
|
||||
metas = {"product": {"F2": ["doc1"], "F11": ["doc2"], "G1": ["doc3"]}}
|
||||
filters = [{"key": "product", "op": "not in", "value": ["F2", "F11"]}]
|
||||
|
||||
assert meta_filter(metas, filters) == ["doc3"]
|
||||
|
||||
|
||||
def test_start_with():
|
||||
# returns chunk where the metadata starts with the value
|
||||
metas = {"name": {"prefix_value": ["doc1"], "other": ["doc2"]}}
|
||||
|
||||
Reference in New Issue
Block a user