1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
pub mod params;
pub mod compound;
pub mod custom;
pub mod full_text;
pub mod geo;
pub mod joining;
pub mod shape;
pub mod span;
pub mod specialized;
pub mod term_level;
pub use self::compound::*;
pub use self::custom::*;
pub use self::full_text::*;
pub use self::geo::*;
pub use self::joining::*;
pub use self::shape::*;
pub use self::span::*;
pub use self::specialized::*;
pub use self::term_level::*;
mod match_all_query;
mod match_none_query;
pub use self::match_all_query::*;
pub use self::match_none_query::*;
use crate::util::*;
macro_rules! query {
($name:ident { $($variant:ident($query:ty)),+ $(,)? }) => {
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
#[allow(missing_docs)]
pub enum $name {
$(
$variant($query),
)*
}
$(
impl From<$query> for $name {
fn from(q: $query) -> Self {
$name::$variant(q)
}
}
)+
$(
impl From<$query> for Option<$name> {
fn from(q: $query) -> Self {
if q.should_skip() {
None
} else {
Some($name::$variant(q))
}
}
}
)+
impl ShouldSkip for $name {
fn should_skip(&self) -> bool {
match self {
$(
$name::$variant(q) => q.should_skip(),
)+
}
}
}
};
}
query!(Query {
Bool(BoolQuery),
Prefix(PrefixQuery),
Regexp(RegexpQuery),
Wildcard(WildcardQuery),
TermsSet(TermsSetQuery),
Term(TermQuery),
TermsValues(TermsQuery<std::collections::BTreeSet<crate::Scalar>>),
TermsLookup(TermsQuery<self::params::TermsLookup>),
Exists(ExistsQuery),
Range(RangeQuery),
Ids(IdsQuery),
ConstantScore(ConstantScoreQuery),
DistanceFeatureDate(DistanceFeatureQuery<chrono::DateTime<chrono::Utc>>),
DistanceFeatureGeo(DistanceFeatureQuery<crate::GeoPoint>),
Match(MatchQuery),
MatchBoolPrefix(MatchBoolPrefixQuery),
MatchPhrasePrefix(MatchPhrasePrefixQuery),
MatchAll(MatchAllQuery),
MatchNone(MatchNoneQuery),
MatchPhrase(MatchPhraseQuery),
MultiMatch(MultiMatchQuery),
Nested(NestedQuery),
Boosting(BoostingQuery),
DisMax(DisMaxQuery),
PercolateDocument(PercolateQuery<serde_json::Value>),
PercolateDocuments(PercolateQuery<Vec<serde_json::Value>>),
PercolateLookup(PercolateQuery<self::params::PercolateLookup>),
FunctionScore(FunctionScoreQuery),
RankFeature(RankFeatureQuery),
RankFeatureSaturation(RankFeatureSaturationQuery),
RankFeatureLogarithm(RankFeatureLogarithmQuery),
RankFeatureSigmoid(RankFeatureSigmoidQuery),
RankFeatureLinear(RankFeatureLinearQuery),
MoreLikeThis(MoreLikeThisQuery),
Fuzzy(FuzzyQuery),
GeoDistance(GeoDistanceQuery),
GeoBoundingBox(GeoBoundingBoxQuery),
Json(JsonQuery),
});