os_query_builder_rs/full_text/intervals/rules/
prefix.rs

1use serde::Serialize;
2
3#[derive(Debug, Default, Clone, Serialize)]
4pub struct PrefixRule {
5    prefix: String,
6    #[serde(skip_serializing_if = "Option::is_none")]
7    analyzer: Option<String>,
8    #[serde(skip_serializing_if = "Option::is_none")]
9    use_field: Option<String>
10}
11
12impl PrefixRule {
13
14    pub fn new() -> Self {
15        Self::default()
16    }
17
18    pub fn prefix<T: Into<String> + Serialize>(self, prefix: T) -> Self {
19        Self {
20            prefix: prefix.into(),
21            ..self
22
23        }
24    }
25    pub fn analyzer<T: Into<String> + Serialize>(self, analyzer: T) -> Self {
26        Self {
27            analyzer: Some(analyzer.into()),
28            ..self
29
30        }
31    }
32    pub fn use_field<T: Into<String> + Serialize>(self, use_field: T) -> Self {
33        Self {
34            use_field: Some(use_field.into()),
35            ..self
36
37        }
38    }
39}