1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Filter expression module for EdgeVec.
//!
//! This module provides a powerful filtering system for vector search queries,
//! allowing users to filter results based on metadata fields.
//!
//! # Architecture
//!
//! The filter subsystem consists of:
//! - **AST (`ast.rs`)**: 27-variant `FilterExpr` enum representing parsed filter expressions
//! - **Parser (`parser.rs`)**: Pest-based parser converting filter strings to AST
//! - **Evaluator (`evaluator.rs`)**: Recursive evaluator with short-circuit optimization
//! - **Error (`error.rs`)**: Comprehensive error types with position information
//!
//! # Example
//!
//! ```rust
//! use std::collections::HashMap;
//! use edgevec::filter::{parse, evaluate, FilterExpr};
//! use edgevec::metadata::MetadataValue;
//!
//! // Parse a filter expression
//! let expr = parse("category = \"gpu\" AND price < 500").unwrap();
//!
//! // Evaluate against metadata
//! let mut metadata = HashMap::new();
//! metadata.insert("category".to_string(), MetadataValue::String("gpu".to_string()));
//! metadata.insert("price".to_string(), MetadataValue::Integer(450));
//!
//! let result = evaluate(&expr, &metadata).unwrap();
//! assert!(result);
//! ```
//!
//! # Grammar
//!
//! The filter syntax supports:
//! - Comparison operators: `=`, `!=`, `<`, `<=`, `>`, `>=`
//! - String operators: `CONTAINS`, `STARTS_WITH`, `ENDS_WITH`, `LIKE`
//! - Array operators: `IN`, `NOT IN`, `ANY`, `ALL`, `NONE`
//! - Range operator: `BETWEEN`
//! - Logical operators: `AND`, `OR`, `NOT`
//! - Null checks: `IS NULL`, `IS NOT NULL`
//!
//! # Implementation Status
//!
//! - [x] W23.1.1: FilterExpr AST enum (27 variants)
//! - [x] W23.1.2: Pest grammar file
//! - [x] W23.1.3: AST builder from parse tree
//! - [x] W23.1.4: Error handling with positions
//! - [x] W23.2.1: Core evaluate() function
//! - [x] W23.2.2: Comparison operators
//! - [x] W23.2.3: String operators
//! - [x] W23.2.4: Array operators
//! - [x] W23.3.1: FilterStrategy enum
//! - [x] W23.3.2: Selectivity estimation (estimate_selectivity)
//! - [x] W23.3.3: FilteredSearcher API (search_filtered)
//! - [x] W23.3.4: Tautology/contradiction detection
// Re-exports for convenience
pub use FilterExpr;
pub use FilterError;
pub use evaluate;
pub use ;
pub use parse;
pub use ;