os_query_builder_rs/misc/
rewrite.rs1use serde::{Serialize, Serializer};
2
3#[derive(Debug, Clone)]
6pub enum Rewrite {
7 ConstantScore,
8 ScoringBoolean,
9 ConstantScoreBoolean,
10 TopTerms(u64),
11 TopTermsBoost(u64),
12 TopTermsBlendedFreqs(u64)
13}
14
15
16impl Serialize for Rewrite {
17 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
18 where
19 S: Serializer,
20 {
21 match self {
22 Rewrite::TopTerms(u) => serializer.serialize_str(format!("top_terms_{}", *u).as_str()),
23 Rewrite::TopTermsBoost(u) => serializer.serialize_str(format!("top_terms_boost_{}", *u).as_str()),
24 Rewrite::TopTermsBlendedFreqs(u) => serializer.serialize_str(format!("top_terms_blended_freqs_{}", *u).as_str()),
25 Rewrite::ConstantScore => serializer.serialize_str("constant_score"),
26 Rewrite::ScoringBoolean => serializer.serialize_str("scoring_boolean"),
27 Rewrite::ConstantScoreBoolean => serializer.serialize_str("constant_score_boolean")
28 }
29 }
30}