mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-11-10 06:43:58 +00:00
chore: Deprecate legacy document/metadata filters (#8004)
This commit is contained in:
parent
7e35280d4f
commit
f19131f13a
@ -2,6 +2,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import warnings
|
||||||
from dataclasses import fields
|
from dataclasses import fields
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Dict, List, Union
|
from typing import Any, Dict, List, Union
|
||||||
@ -103,7 +104,8 @@ def _less_than_equal(document_value: Any, filter_value: Any) -> bool:
|
|||||||
def _in(document_value: Any, filter_value: Any) -> bool:
|
def _in(document_value: Any, filter_value: Any) -> bool:
|
||||||
if not isinstance(filter_value, list):
|
if not isinstance(filter_value, list):
|
||||||
msg = (
|
msg = (
|
||||||
f"Filter value must be a `list` when using operator 'in' or 'not in', received type '{type(filter_value)}'"
|
f"Filter value must be a `list` when using operator 'in' or 'not in', "
|
||||||
|
f"received type '{type(filter_value)}'"
|
||||||
)
|
)
|
||||||
raise FilterError(msg)
|
raise FilterError(msg)
|
||||||
return any(_equal(e, document_value) for e in filter_value)
|
return any(_equal(e, document_value) for e in filter_value)
|
||||||
@ -214,6 +216,13 @@ def convert(filters: Dict[str, Any]) -> Dict[str, Any]:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
warnings.warn(
|
||||||
|
"The use of legacy (Haystack 1.x) filters is deprecated and will be removed in the future. "
|
||||||
|
"Please use the new filter style as described in the documentation - "
|
||||||
|
"https://docs.haystack.deepset.ai/docs/metadata-filtering",
|
||||||
|
DeprecationWarning,
|
||||||
|
)
|
||||||
|
|
||||||
if not isinstance(filters, dict):
|
if not isinstance(filters, dict):
|
||||||
msg = f"Can't convert filters from type '{type(filters)}'"
|
msg = f"Can't convert filters from type '{type(filters)}'"
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
deprecations:
|
||||||
|
- |
|
||||||
|
Haystack 1.x legacy filters are deprecated and will be removed in a future release. Please use the new
|
||||||
|
filter style as described in the documentation - https://docs.haystack.deepset.ai/docs/metadata-filtering
|
||||||
Loading…
x
Reference in New Issue
Block a user