use linkrs_core::types::expr::Expression;
use linkrs_core::types::FulltextEngineType;
use linkrs_fulltext::query::FulltextQuery;
use crate::parser::ast::fulltext::{AlterIndexAction, IndexFieldDef, IndexOptions};
#[derive(Debug, Clone)]
pub enum FulltextManageCommand {
Create {
index_name: String,
schema_name: String,
fields: Vec<IndexFieldDef>,
engine_type: FulltextEngineType,
options: IndexOptions,
if_not_exists: bool,
space_id: u64,
},
Drop {
index_name: String,
if_exists: bool,
},
Alter {
index_name: String,
actions: Vec<AlterIndexAction>,
},
Show {
pattern: Option<String>,
from_schema: Option<String>,
},
Describe {
index_name: String,
},
}
impl FulltextManageCommand {
pub fn is_write(&self) -> bool {
match self {
Self::Create { .. } | Self::Drop { .. } | Self::Alter { .. } => true,
Self::Show { .. } | Self::Describe { .. } => false,
}
}
}
#[derive(Debug, Clone)]
pub enum FulltextSpec {
FulltextManage {
space_name: String,
command: FulltextManageCommand,
},
FulltextSearch {
space_name: String,
space_id: u64,
index_name: String,
structured_query: FulltextQuery,
tag_name: String,
field_name: String,
limit: Option<usize>,
},
FulltextLookup {
space_name: String,
space_id: u64,
index_name: String,
structured_query: FulltextQuery,
tag_name: String,
field_name: String,
limit: Option<usize>,
},
MatchFulltext {
space_name: String,
space_id: u64,
match_expr: Expression,
match_field: Option<String>,
structured_query: FulltextQuery,
tag_name: String,
field_name: String,
limit: Option<usize>,
},
}