Repository navigation
Commit 0026fd1
authored
Python: Combine multiple InMemoryCollection filters with AND (#14540)
### Motivation and Context
`VectorSearchOptions` documents that multiple filters are combined with
AND. `InMemoryCollection._get_filtered_records` combined them with OR,
so a record was kept as soon as one filter matched.
Fixes #14538
### Description
Keep a record only when `all(...)` of the filters match. Single filters
behave as before.
Added two tests (string filters and callable filters). Both fail on main
and pass with the change.
Checked locally: `tests/unit/connectors/memory/test_in_memory.py` and
`tests/unit/data` pass, ruff check and format are clean, mypy is clean
on `in_memory.py`.
### Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄1 parent 50156e3 commit 0026fd1
2 files changed
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
774 | | - | |
775 | | - | |
776 | | - | |
| 774 | + | |
| 775 | + | |
777 | 776 | | |
778 | 777 | | |
779 | 778 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
330 | 352 | | |
331 | 353 | | |
332 | 354 | | |
| |||
0 commit comments