interstellar 0.2.0

A high-performance graph database with Gremlin-style traversals and GQL query language
Documentation
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
//! Abstract Syntax Tree types for Gremlin queries.
//!
//! This module defines the AST representation for parsed Gremlin queries,
//! including source steps, traversal steps, predicates, and literals.

/// Source span for error reporting.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Span {
    /// Start byte offset
    pub start: usize,
    /// End byte offset
    pub end: usize,
}

impl Span {
    /// Create a new span
    pub fn new(start: usize, end: usize) -> Self {
        Self { start, end }
    }
}

/// A complete Gremlin traversal query.
#[derive(Debug, Clone, PartialEq)]
pub struct GremlinTraversal {
    /// The source step (g.V(), g.E(), etc.)
    pub source: SourceStep,
    /// The chain of traversal steps
    pub steps: Vec<Step>,
    /// Optional terminal step (toList, next, etc.)
    pub terminal: Option<TerminalStep>,
    /// Source span for error reporting
    pub span: Span,
}

/// An anonymous traversal (__.out(), __.values(), etc.)
/// Unlike GremlinTraversal, has no source step or terminal.
#[derive(Debug, Clone, PartialEq)]
pub struct AnonymousTraversal {
    /// The chain of traversal steps (may be empty for identity)
    pub steps: Vec<Step>,
    /// Source span for error reporting
    pub span: Span,
}

/// Source steps that initiate a traversal.
#[derive(Debug, Clone, PartialEq)]
pub enum SourceStep {
    /// g.V() - all vertices, g.V(id) - vertex by id, g.V(id, id, ...) - multiple
    V {
        ids: Vec<Literal>,
        /// Variable reference (e.g., g.V(alice))
        variable: Option<String>,
        span: Span,
    },
    /// g.E() - all edges, g.E(id) - edge by id
    E {
        ids: Vec<Literal>,
        /// Variable reference (e.g., g.E(edge_var))
        variable: Option<String>,
        span: Span,
    },
    /// g.addV('label') - create vertex
    AddV { label: String, span: Span },
    /// g.addE('label') - create edge
    AddE { label: String, span: Span },
    /// g.inject(values...) - inject values into traversal
    Inject { values: Vec<Literal>, span: Span },
    /// g.searchTextV('prop', query, k) - top-k vertices by full-text relevance.
    /// (spec-55c)
    SearchTextV {
        /// The indexed string property to search.
        property: String,
        /// The query, either a bare-string sugar (mapped to TextQuery::Match)
        /// or a structured TextQ DSL expression.
        query: TextQueryAst,
        /// Top-k cap.
        k: u64,
        span: Span,
    },
    /// g.searchTextE('prop', query, k) - top-k edges by full-text relevance.
    /// (spec-55c)
    SearchTextE {
        property: String,
        query: TextQueryAst,
        k: u64,
        span: Span,
    },
}

/// Terminal steps that execute the traversal and return results.
#[derive(Debug, Clone, PartialEq)]
pub enum TerminalStep {
    /// .next() or .next(n)
    Next { count: Option<u64>, span: Span },
    /// .toList()
    ToList { span: Span },
    /// .toSet()
    ToSet { span: Span },
    /// .iterate() - execute without collecting
    Iterate { span: Span },
    /// .hasNext()
    HasNext { span: Span },
    /// .explain()
    Explain { span: Span },
}

/// Individual traversal steps.
#[derive(Debug, Clone, PartialEq)]
pub enum Step {
    // ========== Navigation Steps ==========
    /// out(), out('label'), out('label1', 'label2')
    Out { labels: Vec<String>, span: Span },
    /// in(), in('label')
    In { labels: Vec<String>, span: Span },
    /// both(), both('label')
    Both { labels: Vec<String>, span: Span },
    /// outE(), outE('label')
    OutE { labels: Vec<String>, span: Span },
    /// inE(), inE('label')
    InE { labels: Vec<String>, span: Span },
    /// bothE(), bothE('label')
    BothE { labels: Vec<String>, span: Span },
    /// outV()
    OutV { span: Span },
    /// inV()
    InV { span: Span },
    /// bothV()
    BothV { span: Span },
    /// otherV()
    OtherV { span: Span },

    // ========== Filter Steps ==========
    /// has('key'), has('key', value), has('key', P.gt(x)), has('label', 'key', value)
    Has { args: HasArgs, span: Span },
    /// hasLabel('label'), hasLabel('l1', 'l2')
    HasLabel { labels: Vec<String>, span: Span },
    /// hasId(id), hasId(id1, id2)
    HasId { ids: Vec<Literal>, span: Span },
    /// hasNot('key')
    HasNot { key: String, span: Span },
    /// hasKey('key'), hasKey('k1', 'k2')
    HasKey { keys: Vec<String>, span: Span },
    /// hasValue(value), hasValue(v1, v2)
    HasValue { values: Vec<Literal>, span: Span },
    /// where(__.out()), where(P.gt(25))
    Where { args: WhereArgs, span: Span },
    /// is(value), is(P.gt(25))
    Is { args: IsArgs, span: Span },
    /// and(__.out(), __.in())
    And {
        traversals: Vec<AnonymousTraversal>,
        span: Span,
    },
    /// or(__.out(), __.in())
    Or {
        traversals: Vec<AnonymousTraversal>,
        span: Span,
    },
    /// not(__.out())
    Not {
        traversal: Box<AnonymousTraversal>,
        span: Span,
    },
    /// dedup(), dedup('label')
    Dedup {
        by_label: Option<String>,
        span: Span,
    },
    /// limit(n)
    Limit { count: u64, span: Span },
    /// skip(n)
    Skip { count: u64, span: Span },
    /// range(start, end)
    Range { start: u64, end: u64, span: Span },
    /// tail(), tail(n)
    Tail { count: Option<u64>, span: Span },
    /// coin(probability)
    Coin { probability: f64, span: Span },
    /// sample(n)
    Sample { count: u64, span: Span },
    /// simplePath()
    SimplePath { span: Span },
    /// cyclicPath()
    CyclicPath { span: Span },

    // ========== Transform Steps ==========
    /// values('key'), values('k1', 'k2')
    Values { keys: Vec<String>, span: Span },
    /// properties(), properties('key')
    Properties { keys: Vec<String>, span: Span },
    /// valueMap(), valueMap(true), valueMap('k1', 'k2')
    ValueMap { args: ValueMapArgs, span: Span },
    /// elementMap(), elementMap('k1', 'k2')
    ElementMap { keys: Vec<String>, span: Span },
    /// propertyMap(), propertyMap('k1')
    PropertyMap { keys: Vec<String>, span: Span },
    /// id()
    Id { span: Span },
    /// label()
    Label { span: Span },
    /// key()
    Key { span: Span },
    /// value()
    Value { span: Span },
    /// path()
    Path { span: Span },
    /// select('label'), select('l1', 'l2')
    Select { labels: Vec<String>, span: Span },
    /// project('k1', 'k2')
    Project { keys: Vec<String>, span: Span },
    /// by('key'), by(__.values('x')), by(asc)
    By { args: ByArgs, span: Span },
    /// unfold()
    Unfold { span: Span },
    /// fold()
    Fold { span: Span },
    /// count()
    Count { span: Span },
    /// sum()
    Sum { span: Span },
    /// max()
    Max { span: Span },
    /// min()
    Min { span: Span },
    /// mean()
    Mean { span: Span },
    /// group()
    Group { span: Span },
    /// groupCount()
    GroupCount { span: Span },
    /// order()
    Order { span: Span },
    /// math('a + b')
    Math { expression: String, span: Span },
    /// constant(value)
    Constant { value: Literal, span: Span },
    /// identity()
    Identity { span: Span },
    /// index()
    Index { span: Span },
    /// loops()
    Loops { span: Span },
    /// textScore() - read BM25 relevance score from the traverser sack
    /// populated by `g.searchTextV` / `g.searchTextE`. Emits one
    /// `Literal::Float`-backed value per traverser. (spec-55c)
    TextScore { span: Span },

    // ========== Branch Steps ==========
    /// choose(cond, true_trav, false_trav), choose(__.values('type'))
    Choose { args: ChooseArgs, span: Span },
    /// union(__.out(), __.in())
    Union {
        traversals: Vec<AnonymousTraversal>,
        span: Span,
    },
    /// coalesce(__.out(), __.in())
    Coalesce {
        traversals: Vec<AnonymousTraversal>,
        span: Span,
    },
    /// optional(__.out())
    Optional {
        traversal: Box<AnonymousTraversal>,
        span: Span,
    },
    /// local(__.out())
    Local {
        traversal: Box<AnonymousTraversal>,
        span: Span,
    },
    /// branch(__.values('type'))
    Branch {
        traversal: Box<AnonymousTraversal>,
        span: Span,
    },
    /// option('key', __.out()), option(none, __.identity())
    Option { args: OptionArgs, span: Span },

    // ========== Repeat Steps ==========
    /// repeat(__.out())
    Repeat {
        traversal: Box<AnonymousTraversal>,
        span: Span,
    },
    /// times(n)
    Times { count: u32, span: Span },
    /// until(__.hasLabel('target'))
    Until {
        traversal: Box<AnonymousTraversal>,
        span: Span,
    },
    /// emit(), emit(__.hasLabel('person'))
    Emit {
        traversal: Option<Box<AnonymousTraversal>>,
        span: Span,
    },

    // ========== Side Effect Steps ==========
    /// as('label')
    As { label: String, span: Span },
    /// aggregate('x')
    Aggregate { key: String, span: Span },
    /// store('x')
    Store { key: String, span: Span },
    /// cap('x'), cap('x', 'y')
    Cap { keys: Vec<String>, span: Span },
    /// sideEffect(__.out())
    SideEffect {
        traversal: Box<AnonymousTraversal>,
        span: Span,
    },
    /// profile(), profile('metrics')
    Profile { key: Option<String>, span: Span },

    // ========== Algorithm Steps ==========
    /// shortestPath(targetId) - unweighted shortest path to target
    /// Optionally followed by .by('weight') for Dijkstra, and
    /// .with('heuristic', 'prop') for A*.
    ShortestPath {
        target: Literal,
        span: Span,
    },
    /// kShortestPaths(targetId, k) - Yen's k-shortest loopless paths
    /// Followed by .by('weight') for the weight property.
    KShortestPaths {
        target: Literal,
        k: u64,
        span: Span,
    },
    /// bfs() - breadth-first search traversal from current vertex
    /// Optional .with('maxDepth', n), .with('edgeLabels', ['l1', 'l2'])
    BfsTraversal { span: Span },
    /// dfs() - depth-first search traversal from current vertex
    /// Optional .with('maxDepth', n), .with('edgeLabels', ['l1', 'l2'])
    DfsTraversal { span: Span },
    /// bidirectionalBfs(targetId) - bidirectional BFS shortest path
    BidirectionalBfs {
        target: Literal,
        span: Span,
    },
    /// iddfs(targetId, maxDepth) - iterative deepening DFS
    Iddfs {
        target: Literal,
        max_depth: u32,
        span: Span,
    },
    /// with('key', value) - configuration modulator for algorithm steps
    With { args: WithArgs, span: Span },

    // ========== Mutation Steps ==========
    /// addV('label') - inline (not source)
    AddV { label: String, span: Span },
    /// addE('label') - inline (not source)
    AddE { label: String, span: Span },
    /// property('key', value), property(Cardinality.single, 'key', value)
    Property { args: PropertyArgs, span: Span },
    /// from('label'), from(__.select('a'))
    From { args: FromToArgs, span: Span },
    /// to('label'), to(__.select('b'))
    To { args: FromToArgs, span: Span },
    /// drop()
    Drop { span: Span },
}

/// Arguments for has() step.
#[derive(Debug, Clone, PartialEq)]
pub enum HasArgs {
    /// has('key') - key existence
    Key(String),
    /// has('key', value) - key equals value
    KeyValue { key: String, value: Literal },
    /// has('key', P.gt(x)) - key matches predicate
    KeyPredicate { key: String, predicate: Predicate },
    /// has('label', 'key', value) - label + key + value
    LabelKeyValue {
        label: String,
        key: String,
        value: Literal,
    },
}

/// Arguments for where() step.
#[derive(Debug, Clone, PartialEq)]
pub enum WhereArgs {
    /// where(__.out())
    Traversal(Box<AnonymousTraversal>),
    /// where(P.eq('value'))
    Predicate(Predicate),
}

/// Arguments for is() step.
#[derive(Debug, Clone, PartialEq)]
pub enum IsArgs {
    /// is(value)
    Value(Literal),
    /// is(P.gt(x))
    Predicate(Predicate),
}

/// Arguments for valueMap() step.
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ValueMapArgs {
    /// Include id and label tokens (valueMap(true))
    pub include_tokens: bool,
    /// Specific keys to include
    pub keys: Vec<String>,
}

/// Arguments for by() modulator.
#[derive(Debug, Clone, PartialEq)]
pub enum ByArgs {
    /// by() - identity
    Identity,
    /// by('key')
    Key(String),
    /// by(__.values('name'))
    Traversal(Box<AnonymousTraversal>),
    /// by(asc), by(desc)
    Order(OrderDirection),
    /// by('key', asc)
    KeyOrder { key: String, order: OrderDirection },
    /// by(__.values('x'), asc)
    TraversalOrder {
        traversal: Box<AnonymousTraversal>,
        order: OrderDirection,
    },
}

/// Order direction for sorting.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OrderDirection {
    /// Ascending order
    Asc,
    /// Descending order
    Desc,
    /// Random shuffle
    Shuffle,
}

/// Arguments for choose() step.
#[derive(Debug, Clone, PartialEq)]
pub enum ChooseArgs {
    /// choose(cond, true_trav, false_trav)
    IfThenElse {
        condition: Box<AnonymousTraversal>,
        if_true: Box<AnonymousTraversal>,
        if_false: Box<AnonymousTraversal>,
    },
    /// choose(__.values('type')) - for use with option()
    ByTraversal(Box<AnonymousTraversal>),
    /// choose(P.gt(25))
    ByPredicate(Predicate),
}

/// Arguments for option() step.
#[derive(Debug, Clone, PartialEq)]
pub enum OptionArgs {
    /// option('key', __.out())
    KeyValue {
        key: Literal,
        traversal: Box<AnonymousTraversal>,
    },
    /// option(none, __.identity())
    None { traversal: Box<AnonymousTraversal> },
}

/// Arguments for property() step.
#[derive(Debug, Clone, PartialEq)]
pub struct PropertyArgs {
    /// Optional cardinality (single, list, set)
    pub cardinality: Option<Cardinality>,
    /// Property key
    pub key: String,
    /// Property value
    pub value: Literal,
}

/// Property cardinality.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Cardinality {
    /// Single value (default)
    Single,
    /// List of values
    List,
    /// Set of unique values
    Set,
}

/// Arguments for from()/to() steps.
#[derive(Debug, Clone, PartialEq)]
pub enum FromToArgs {
    /// from('label') - select by as() label
    Label(String),
    /// from(__.select('a'))
    Traversal(Box<AnonymousTraversal>),
    /// from(vertexId)
    Id(Literal),
    /// from(variable) - reference to a script variable
    Variable(String),
}

/// Arguments for with() modulator.
#[derive(Debug, Clone, PartialEq)]
pub struct WithArgs {
    /// Configuration key (e.g., "heuristic", "maxDepth", "direction", "edgeLabels", "k")
    pub key: String,
    /// Configuration value
    pub value: Literal,
}

/// Predicate for filtering.
#[derive(Debug, Clone, PartialEq)]
pub enum Predicate {
    // Comparison predicates
    /// P.eq(value)
    Eq(Literal),
    /// P.neq(value)
    Neq(Literal),
    /// P.lt(value)
    Lt(Literal),
    /// P.lte(value)
    Lte(Literal),
    /// P.gt(value)
    Gt(Literal),
    /// P.gte(value)
    Gte(Literal),

    // Range predicates
    /// P.between(start, end) - [start, end)
    Between { start: Literal, end: Literal },
    /// P.inside(start, end) - (start, end)
    Inside { start: Literal, end: Literal },
    /// P.outside(start, end)
    Outside { start: Literal, end: Literal },

    // Collection predicates
    /// P.within(values...)
    Within(Vec<Literal>),
    /// P.without(values...)
    Without(Vec<Literal>),

    // Logical predicates
    /// P.and(p1, p2)
    And(Box<Predicate>, Box<Predicate>),
    /// P.or(p1, p2)
    Or(Box<Predicate>, Box<Predicate>),
    /// P.not(p)
    Not(Box<Predicate>),

    // Text predicates
    /// TextP.containing(s)
    Containing(String),
    /// TextP.notContaining(s)
    NotContaining(String),
    /// TextP.startingWith(s)
    StartingWith(String),
    /// TextP.notStartingWith(s)
    NotStartingWith(String),
    /// TextP.endingWith(s)
    EndingWith(String),
    /// TextP.notEndingWith(s)
    NotEndingWith(String),
    /// TextP.regex(pattern)
    Regex(String),

    // Geospatial predicates (spec-56)
    /// geo_within_distance(geometry, distance)
    GeoWithinDistance {
        geometry: Literal,
        distance: Literal,
    },
    /// geo_intersects(geometry)
    GeoIntersects(Literal),
    /// geo_contained_by(polygon)
    GeoContainedBy(Literal),
    /// geo_bbox(min_lon, min_lat, max_lon, max_lat)
    GeoBBox {
        min_lon: f64,
        min_lat: f64,
        max_lon: f64,
        max_lat: f64,
    },
}

/// Literal values in Gremlin queries.
#[derive(Debug, Clone, PartialEq)]
pub enum Literal {
    /// String value
    String(String),
    /// Integer value
    Int(i64),
    /// Floating-point value
    Float(f64),
    /// Boolean value
    Bool(bool),
    /// Null value
    Null,
    /// List of values
    List(Vec<Literal>),
    /// Map of key-value pairs
    Map(Vec<(String, Literal)>),
    /// Geospatial point: point(lon, lat) (spec-56)
    Point { lon: f64, lat: f64 },
    /// Geospatial polygon: polygon([[lon,lat], ...]) (spec-56)
    Polygon(Vec<(f64, f64)>),
    /// Distance with unit: 5km, 100m, 3.2mi, 10nmi (spec-56)
    Distance { value: f64, unit: DistanceUnit },
}

// ============================================================
// Multi-Statement Script Types
// ============================================================

/// A complete Gremlin script containing one or more statements.
///
/// Scripts support variable assignment and reference:
/// ```gremlin
/// alice = g.addV('person').property('name', 'Alice').next()
/// bob = g.addV('person').property('name', 'Bob').next()
/// g.addE('knows').from(alice).to(bob).next()
/// g.V(alice).out('knows').values('name').toList()
/// ```
#[derive(Debug, Clone, PartialEq)]
pub struct Script {
    /// The statements in this script
    pub statements: Vec<Statement>,
    /// Source span for error reporting
    pub span: Span,
}

/// A single statement in a Gremlin script.
#[derive(Debug, Clone, PartialEq)]
pub enum Statement {
    /// Variable assignment: `name = traversal`
    Assignment {
        /// The variable name being assigned to
        name: String,
        /// The traversal that produces the value
        traversal: GremlinTraversal,
        /// Source span for error reporting
        span: Span,
    },
    /// Standalone traversal execution
    Traversal {
        /// The traversal to execute
        traversal: GremlinTraversal,
        /// Source span for error reporting
        span: Span,
    },
}

/// Extended source step vertex specification for variable support.
#[derive(Debug, Clone, PartialEq)]
pub enum VertexSource {
    /// All vertices (g.V())
    All,
    /// Specific vertex IDs (g.V(1, 2, 3))
    Ids(Vec<Literal>),
    /// Variable reference (g.V(alice))
    Variable(String),
}

/// Extended edge endpoint specification for variable support.
#[derive(Debug, Clone, PartialEq)]
pub enum EdgeEndpoint {
    /// Explicit vertex ID
    VertexId(Literal),
    /// Reference to a step label (from('a'))
    StepLabel(String),
    /// Reference to a variable (from(alice))
    Variable(String),
    /// Sub-traversal that produces a vertex
    Traversal(Box<AnonymousTraversal>),
}

/// Structured full-text query for `g.searchTextV` / `g.searchTextE`.
///
/// Mirrors the `interstellar::storage::text::TextQuery` runtime enum. The
/// compiler converts this AST node into the runtime type before invoking
/// the FTS engine. Bare-string syntax in the grammar (e.g.,
/// `searchTextV('body', 'raft', 10)`) is sugared into [`TextQueryAst::Match`].
///
/// (spec-55c §3.2 — Gremlin TextQ DSL.)
#[derive(Debug, Clone, PartialEq)]
pub enum TextQueryAst {
    /// `TextQ.match('term1 term2')` — OR-of-tokens (disjunctive).
    Match(String),
    /// `TextQ.matchAll('term1 term2')` — AND-of-tokens (conjunctive).
    MatchAll(String),
    /// `TextQ.phrase('quick brown fox')` — exact phrase match.
    Phrase(String),
    /// `TextQ.prefix('foo')` — prefix expansion.
    Prefix(String),
    /// `TextQ.and(q1, q2, ...)` — conjunction of structured queries.
    And(Vec<TextQueryAst>),
    /// `TextQ.or(q1, q2, ...)` — disjunction of structured queries.
    Or(Vec<TextQueryAst>),
    /// `TextQ.not(q)` — negation of a structured query.
    Not(Box<TextQueryAst>),
}

/// Distance unit for geo queries (spec-56).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DistanceUnit {
    /// Meters
    Meters,
    /// Kilometers
    Kilometers,
    /// Statute miles
    Miles,
    /// Nautical miles
    NauticalMiles,
}