BlogsMilvusRegex Filtering

Regex Filtering

Regex Filtering

1
posts
2026

Milvus 3.0 introduces native regex filtering capabilities with `=~` and `!~` operators. This allows for complex string pattern matching directly within database queries, integrating seamlessly with vector search, full-text search, and scalar filters. The implementation leverages RE2 for predictable performance and includes optimizations like NGRAM indexing for efficient candidate generation and filtering. The system handles user-supplied patterns, null semantics, and query planning to ensure predictable cost and accurate results across millions of strings.

2026

Beyond =~: How Milvus 3.0 Turns Regex into a Native Database Filter

8/5/2026

Introduced native regex filtering operators (`=~`, `!~`) into Milvus 3.0, moving regex processing from application-side post-processing to the database query path. This involves validating user-supplied patterns using RE2 for predictable linear execution time, preserving null and negation semantics, integrating regex with query planning and indexing, and implementing optimizations such as rewriting simple regex to cheaper string operations (equality, prefix, suffix), treating regex as a heavy predicate to be executed after cheaper conditions, using Volnitsky string search as a prefilter for patterns with stable literals, and leveraging NGRAM indexing for candidate generation and subsequent RE2 verification. The implementation also addresses the correct handling of `!~` with UNKNOWN values in three-valued logic.