os_query_builder_rs/full_text/intervals/rules/
match.rs1use serde::Serialize;
2use crate::full_text::intervals::rules::filter::FilterRule;
3
4#[derive(Debug, Default, Clone, Serialize)]
5pub struct MatchRule {
6 query: String,
7 #[serde(skip_serializing_if = "Option::is_none")]
8 analyzer: Option<String>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 max_gaps: Option<i64>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 ordered: Option<bool>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 use_field: Option<String>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 filter: Option<Box<FilterRule>>
17}
18
19impl MatchRule {
20
21 pub fn new() -> Self {
22 Self::default()
23 }
24
25 pub fn query<T: Into<String> + Serialize>(self, query: T) -> Self {
26 Self {
27 query: query.into(),
28 ..self
29 }
30 }
31
32 pub fn analyzer<T: Into<String> + Serialize>(self, analyzer: T) -> Self {
33 Self {
34 analyzer: Some(analyzer.into()),
35 ..self
36 }
37 }
38
39 pub fn max_gaps<T: Into<i64> + Serialize>(self, max_gaps: T) -> Self {
40 Self {
41 max_gaps: Some(max_gaps.into()),
42 ..self
43 }
44 }
45
46 pub fn ordered<T: Into<bool> + Serialize>(self, ordered: T) -> Self {
47 Self {
48 ordered: Some(ordered.into()),
49 ..self
50 }
51 }
52
53 pub fn use_field<T: Into<String> + Serialize>(self, use_field: T) -> Self {
54 Self {
55 use_field: Some(use_field.into()),
56 ..self
57 }
58 }
59
60 pub fn filter<T: Into<FilterRule> + Serialize>(self, filter: T) -> Self {
61 Self {
62 filter: Some(Box::new(filter.into())),
63 ..self
64 }
65 }
66}