add comments

This commit is contained in:
Pascal Seitz
2022-04-14 12:06:36 +08:00
parent 4b6047f7d7
commit ab6b532cc4
4 changed files with 9 additions and 8 deletions

View File

@@ -122,7 +122,7 @@ fn main() -> tantivy::Result<()> {
let searcher = reader.searcher();
let agg_res: AggregationResults = searcher.search(&term_query, &collector).unwrap();
let res: Value = serde_json::from_str(&serde_json::to_string(&agg_res)?)?;
let res: Value = serde_json::to_value(&agg_res)?;
println!("{}", serde_json::to_string_pretty(&res)?);
Ok(())

View File

@@ -121,7 +121,7 @@ impl MetricAggregationWithAccessor {
Ok(MetricAggregationWithAccessor {
accessor: accessor
.as_single()
.expect("unexpected fast field cardinatility")
.expect("unexpected fast field cardinality")
.clone(),
field_type,
metric: metric.clone(),
@@ -173,9 +173,9 @@ fn get_ff_reader_and_validate(
if let Some((ff_type, field_cardinality)) = type_and_cardinality(field_type) {
if ff_type == FastType::Date {
return Err(TantivyError::InvalidArgument(format!(
"Unsupported field type date in aggregation"
)));
return Err(TantivyError::InvalidArgument(
"Unsupported field type date in aggregation".to_string(),
));
}
if cardinality != field_cardinality {

View File

@@ -110,7 +110,8 @@ pub(crate) struct SegmentRangeBucketEntry {
pub sub_aggregation: Option<SegmentAggregationResultsCollector>,
/// The from range of the bucket. Equals f64::MIN when None.
pub from: Option<f64>,
/// The to range of the bucket. Equals f64::MAX when None.
/// The to range of the bucket. Equals f64::MAX when None. Open interval, `to` is not
/// inclusive.
pub to: Option<f64>,
}

View File

@@ -363,6 +363,7 @@ mod tests {
searcher.search(&AllQuery, &collector)?
};
// Test serialization/deserialization rountrip
let res: Value = serde_json::from_str(&serde_json::to_string(&agg_res)?)?;
Ok(res)
}
@@ -544,7 +545,6 @@ mod tests {
};
let res: Value = serde_json::from_str(&serde_json::to_string(&agg_res)?)?;
// println!("{}", serde_json::to_string_pretty(&res).unwrap());
assert_eq!(res["bucketsL1"]["buckets"][0]["doc_count"], 3);
assert_eq!(
@@ -1138,7 +1138,7 @@ mod tests {
let score_field_i64 = schema_builder.add_i64_field("score_i64", score_fieldtype);
let index = Index::create_from_tempdir(schema_builder.build())?;
let few_terms_data = vec!["INFO", "ERROR", "WARN", "DEBUG"];
let many_terms_data = (0..150_000)
let many_terms_data = (0..15_000)
.map(|num| format!("author{}", num))
.collect::<Vec<_>>();
{