-
Notifications
You must be signed in to change notification settings - Fork 4.3k
.Net: feat: Eliminate obsolete VectorSearchFilter technical debt in VectorStoreTextSearch (microsoft#10456) #13179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature-text-search-linq
Are you sure you want to change the base?
Conversation
…obsolete VectorSearchFilter - Replace obsolete VectorSearchFilter conversion with direct LINQ filtering for simple equality filters - Add ConvertTextSearchFilterToLinq() method to handle TextSearchFilter.Equality() cases - Fall back to legacy approach only for complex filters that cannot be converted - Eliminates technical debt and performance overhead identified in Issue microsoft#10456 - Maintains 100% backward compatibility - all existing tests pass (1,574/1,574) - Reduces object allocations and removes obsolete API warnings for common filtering scenarios Addresses Issue microsoft#10456 - PR 2: VectorStoreTextSearch internal modernization
0e78309
to
3c9fc7b
Compare
…pliance - Replace broad catch-all exception handling with specific exception types - Add comprehensive exception handling for reflection operations in CreateEqualityExpression: * ArgumentNullException for null parameters * ArgumentException for invalid property names or expression parameters * InvalidOperationException for invalid property access or operations * TargetParameterCountException for lambda expression parameter mismatches * MemberAccessException for property access permission issues * NotSupportedException for unsupported operations (e.g., byref-like parameters) - Maintain intentional catch-all Exception handler with #pragma warning disable CA1031 - Preserve backward compatibility by returning null for graceful fallback - Add clear documentation explaining exception handling rationale - Addresses CA1031 code analysis warning while maintaining robust error handling - All tests pass (1,574/1,574) and formatting compliance verified
@moonbox3 @roji @markwallace-microsoft can you please trigger the review workflows? Thanks |
- Add InvalidPropertyFilterThrowsExpectedExceptionAsync: Validates that new LINQ filtering creates expressions correctly and passes them to vector store connectors - Add ComplexFiltersUseLegacyBehaviorAsync: Tests graceful fallback for complex filter scenarios when LINQ conversion returns null - Add SimpleEqualityFilterUsesModernLinqPathAsync: Confirms end-to-end functionality of the new LINQ filtering optimization for simple equality filters Analysis: - All 15 VectorStoreTextSearch tests pass (3 new + 12 existing) - All 85 TextSearch tests pass, confirming no regressions - Tests prove the new ConvertTextSearchFilterToLinq() and CreateEqualityExpression() methods work correctly - Exception from InMemory connector in invalid property test confirms LINQ path is being used instead of fallback behavior - Improves edge case coverage for the filtering modernization introduced in previous commits
- Add NullFilterReturnsAllResultsAsync test to verify behavior when no filter is applied - Remove unnecessary Microsoft.Extensions.VectorData using statement - Enhance test coverage for VectorStoreTextSearch edge cases
…INQ filtering - Extend ConvertTextSearchFilterToLinq to handle AnyTagEqualToFilterClause - Add CreateAnyTagEqualToExpression for collection.Contains() operations - Add CreateMultipleClauseExpression for AND logic with Expression.AndAlso - Add 4 comprehensive tests for new filtering capabilities - Add RequiresDynamicCode attributes for AOT compatibility - Maintain backward compatibility with graceful fallback Fixes microsoft#10456
Fixes IL3051 compilation errors by adding RequiresDynamicCode attributes to: - SearchAsync(string, TextSearchOptions<TRecord>?, CancellationToken) - GetTextSearchResultsAsync(string, TextSearchOptions<TRecord>?, CancellationToken) - GetSearchResultsAsync(string, TextSearchOptions<TRecord>?, CancellationToken) The generic ITextSearch<TRecord> interface accepts LINQ expressions via TextSearchOptions<TRecord>.Filter, which requires dynamic code generation for expression tree processing. This change ensures interface methods match their implementations' RequiresDynamicCode attributes. Resolves: Issue microsoft#10456 IL3051 interface mismatch errors Cherry-pick-safe: Interface-only change, no implementation logic
- Fix CA1859: Use specific return types BinaryExpression? and MethodCallExpression? instead of generic Expression? for better performance - Improve test model: Use IReadOnlyList<string> instead of string[] for Tags property to follow .NET collection best practices These changes address code analyzer warnings and apply reviewer applicable feedback from other PRs in the Issue microsoft#10456 modernization series.
- Remove LINQ dependency from non-generic ITextSearch interface - Revert non-generic methods to direct VectorSearchFilter usage - Eliminates IL3051 warnings by avoiding RequiresDynamicCode on non-generic interface - Preserves backward compatibility with legacy TextSearchFilter path - Maintains modern LINQ expressions for generic ITextSearch<TRecord> interface Architectural separation: - Non-generic: TextSearchOptions → VectorSearchFilter (legacy path) - Generic: TextSearchOptions<TRecord> → Expression<Func<TRecord, bool>> (LINQ path) Resolves remaining IL3051 compilation errors while maintaining Issue microsoft#10456 objectives.
status: proposed
|
Modernize VectorStoreTextSearch internal implementation
Problem Statement
VectorStoreTextSearch contains internal technical debt where simple LINQ expressions are unnecessarily converted to VectorSearchFilter objects before being processed, creating performance overhead and implementation complexity identified in Issue #10456.
Technical Approach
The implementation removes unnecessary conversion layers between LINQ expressions and vector store operations, enabling direct expression processing where appropriate.
Key Optimizations
Implementation Details
Core Changes
Code Examples
Before (Internal Technical Debt)
After (Optimized Internal Processing)
Implementation Benefits
Code Quality
Validation Results
Build Verification
Test Coverage
Compatibility Verification
Files Modified
Breaking Changes
None. These are internal-only modifications that preserve external API behavior.
Multi-PR Context
This is PR 2 of 6 in the structured implementation approach for Issue #10456. This PR builds on the generic interfaces from PR1 to eliminate internal technical debt in VectorStoreTextSearch while maintaining external API compatibility.