Skip to main content

linkrs_query/executor/streaming/operators/spec/
fulltext.rs

1//! Immutable configuration for fulltext search operators.
2
3use linkrs_core::types::expr::Expression;
4use linkrs_core::types::FulltextEngineType;
5use linkrs_fulltext::query::FulltextQuery;
6
7use crate::parser::ast::fulltext::{AlterIndexAction, IndexFieldDef, IndexOptions};
8
9/// Fulltext index DDL command payload.
10#[derive(Debug, Clone)]
11pub enum FulltextManageCommand {
12    Create {
13        index_name: String,
14        schema_name: String,
15        fields: Vec<IndexFieldDef>,
16        engine_type: FulltextEngineType,
17        options: IndexOptions,
18        if_not_exists: bool,
19        space_id: u64,
20    },
21    Drop {
22        index_name: String,
23        if_exists: bool,
24    },
25    Alter {
26        index_name: String,
27        actions: Vec<AlterIndexAction>,
28    },
29    Show {
30        pattern: Option<String>,
31        from_schema: Option<String>,
32    },
33    Describe {
34        index_name: String,
35    },
36}
37
38impl FulltextManageCommand {
39    /// Whether the command mutates stored state.
40    pub fn is_write(&self) -> bool {
41        match self {
42            Self::Create { .. } | Self::Drop { .. } | Self::Alter { .. } => true,
43            Self::Show { .. } | Self::Describe { .. } => false,
44        }
45    }
46}
47
48/// Immutable config for fulltext search operators.
49#[derive(Debug, Clone)]
50pub enum FulltextSpec {
51    FulltextManage {
52        space_name: String,
53        command: FulltextManageCommand,
54    },
55    FulltextSearch {
56        space_name: String,
57        space_id: u64,
58        index_name: String,
59        structured_query: FulltextQuery,
60        tag_name: String,
61        field_name: String,
62        limit: Option<usize>,
63    },
64    FulltextLookup {
65        space_name: String,
66        space_id: u64,
67        index_name: String,
68        structured_query: FulltextQuery,
69        tag_name: String,
70        field_name: String,
71        limit: Option<usize>,
72    },
73    MatchFulltext {
74        space_name: String,
75        space_id: u64,
76        match_expr: Expression,
77        match_field: Option<String>,
78        /// Structured query built from the fulltext match condition.
79        structured_query: FulltextQuery,
80        tag_name: String,
81        field_name: String,
82        limit: Option<usize>,
83    },
84}