Module tantivy::aggregation::agg_req
source · [−]Expand description
Contains the aggregation request tree. Used to build an AggregationCollector.
Aggregations is the top level entry point to create a request, which is a HashMap<String, Aggregation>
.
Requests are compatible with the json format of elasticsearch.
Example
use tantivy::aggregation::bucket::RangeAggregation;
use tantivy::aggregation::agg_req::BucketAggregationType;
use tantivy::aggregation::agg_req::{Aggregation, Aggregations};
use tantivy::aggregation::agg_req::BucketAggregation;
let agg_req1: Aggregations = vec![
(
"range".to_string(),
Aggregation::Bucket(BucketAggregation {
bucket_agg: BucketAggregationType::Range(RangeAggregation{
field: "score".to_string(),
ranges: vec![(3f64..7f64).into(), (7f64..20f64).into()],
}),
sub_aggregation: Default::default(),
}),
),
]
.into_iter()
.collect();
let elasticsearch_compatible_json_req = r#"
{
"range": {
"range": {
"field": "score",
"ranges": [
{ "from": 3.0, "to": 7.0 },
{ "from": 7.0, "to": 20.0 }
]
}
}
}"#;
let agg_req2: Aggregations = serde_json::from_str(elasticsearch_compatible_json_req).unwrap();
assert_eq!(agg_req1, agg_req2);
Structs
BucketAggregations create buckets of documents. Each bucket is associated with a rule which determines whether or not a document in the falls into it. In other words, the buckets effectively define document sets. Buckets are not necessarily disjunct, therefore a document can fall into multiple buckets. In addition to the buckets themselves, the bucket aggregations also compute and return the number of documents for each bucket. Bucket aggregations, as opposed to metric aggregations, can hold sub-aggregations. These sub-aggregations will be aggregated for the buckets created by their “parent” bucket aggregation. There are different bucket aggregators, each with a different “bucketing” strategy. Some define a single bucket, some define fixed number of multiple buckets, and others dynamically create the buckets during the aggregation process.
Provide user-defined buckets to aggregate on.
Two special buckets will automatically be created to cover the whole range of values.
The provided buckets have to be continous.
During the aggregation, the values extracted from the fast_field field
will be checked
against each bucket range. Note that this aggregation includes the from value and excludes the
to value for each range.
Enums
Aggregation request of BucketAggregation or MetricAggregation.
The bucket aggregation types.
The aggregations in this family compute metrics based on values extracted from the documents that are being aggregated. Values are extracted from the fast field of the document. Some aggregations output a single numeric metric (e.g. Average) and are called single-value numeric metrics aggregation, others generate multiple metrics (e.g. Stats) and are called multi-value numeric metrics aggregation.
Functions
Extract all fast field names used in the tree.
Extract all fields, where the term directory is used in the tree.
Type Definitions
The top-level aggregation request structure, which contains Aggregation and their user defined names. It is also used in buckets to define sub-aggregations.