Commit 7281998
Add filter support for VSIM vector search (#1570)
* Add post-filter support for VSIM vector search results
Implement JSON-path-based filter expressions that are evaluated against
vector element attributes after similarity search. The filter engine
includes a tokenizer, expression parser, and evaluator supporting
comparison operators, logical operators (and/or/not), arithmetic,
string equality, containment (in), and parenthesized grouping.
Integrate post-filtering into VectorManager for both VSIM code paths,
rejecting requests that specify a filter without WITHATTRIBS.
* fix format
* Update libs/server/Resp/Vector/VectorManager.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Avoid per-result byte array allocation in EvaluateFilter (#1571)
* Initial plan
* Avoid per-result allocation in EvaluateFilter by using Utf8JsonReader with ParseValue
Co-authored-by: hailangx <3389245+hailangx@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: hailangx <3389245+hailangx@users.noreply.github.com>
* VSIM FILTER works without WITHATTRIBS by fetching attributes internally (#1572)
* Initial plan
* Fetch attributes internally for filtering when not returning them
Co-authored-by: hailangx <3389245+hailangx@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: hailangx <3389245+hailangx@users.noreply.github.com>
* optimize code
* add Supported vector filter syntax
* update doc with syntac
* fix build
* update test with ELE style syntax
* split the filter engine tests
* remove object value type
* remove object-returning property
* fix format error
* resove comments
* refactor to stack-based postfix
* remove hot path allocate
* Fix formatting: remove trailing newlines per editorconfig
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* optimize allocate
* fix test
* reusable evaluation stack with default capacity (16)
* use stack with default 16 capacity to minimize the allocation as most of the filters should just fit in
* add more tests for attribute extractor
* add benchmark
* optimize the allocate
* orgnize the benchmarks and ordered by real-world frequency
* refactor
* avoid memory copy for final results output
* refactor to all use slicing for josn extraction
* Single-pass extraction for all fields
* refactor to all use ReadOnlySpan<byte>
* removing the filter folder
* refactor to no heap allocation
* All buffers are stackalloc'd on the thread stack
* clean up unused methods
* fix format
* use maxFilteringEffort for filtering
* use ArrayPool instead of stackalloc
* update the design doc
* update design doc
* use scratchBufferBuilder
* move ScratchBufferBuilder up
---------
Co-authored-by: Haiyang Xu <haixu@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: CI Fix <fix@ci.local>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 1b695ef commit 7281998
File tree
19 files changed
+4703
-43
lines changed- benchmark/BDN.benchmark/Filter
- libs/server
- API
- Resp/Vector
- Storage/Session/MainStore
- test/Garnet.test
- website/docs/dev
19 files changed
+4703
-43
lines changedLines changed: 551 additions & 0 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | | - | |
524 | | - | |
| 523 | + | |
| 524 | + | |
525 | 525 | | |
526 | 526 | | |
527 | | - | |
528 | | - | |
| 527 | + | |
| 528 | + | |
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
653 | | - | |
| 653 | + | |
654 | 654 | | |
655 | 655 | | |
656 | | - | |
| 656 | + | |
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
660 | | - | |
| 660 | + | |
661 | 661 | | |
662 | 662 | | |
663 | | - | |
| 663 | + | |
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2041 | 2041 | | |
2042 | 2042 | | |
2043 | 2043 | | |
2044 | | - | |
| 2044 | + | |
2045 | 2045 | | |
2046 | 2046 | | |
2047 | 2047 | | |
2048 | 2048 | | |
2049 | 2049 | | |
2050 | 2050 | | |
2051 | 2051 | | |
2052 | | - | |
| 2052 | + | |
2053 | 2053 | | |
2054 | 2054 | | |
2055 | 2055 | | |
| |||
0 commit comments