Skip to content

Commit ef32cbb

Browse files
committed
Doc test passing
1 parent c3d926b commit ef32cbb

18 files changed

+440
-700
lines changed

src/aggregation/metric/top_hits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::aggregation::intermediate_agg_result::{
1515
IntermediateAggregationResult, IntermediateMetricResult,
1616
};
1717
use crate::aggregation::segment_agg_result::SegmentAggregationCollector;
18-
use crate::aggregation::top_n_computer::TopNComputer;
1918
use crate::aggregation::AggregationError;
19+
use crate::collector::TopNComputer;
2020
use crate::schema::OwnedValue;
2121
use crate::{DocAddress, DocId, SegmentOrdinal};
2222
// duplicate import removed; already imported above
@@ -644,8 +644,8 @@ mod tests {
644644
use crate::aggregation::agg_result::AggregationResults;
645645
use crate::aggregation::bucket::tests::get_test_index_from_docs;
646646
use crate::aggregation::tests::get_test_index_from_values;
647-
use crate::aggregation::top_n_computer::ComparableDoc;
648647
use crate::aggregation::AggregationCollector;
648+
use crate::collector::ComparableDoc;
649649
use crate::query::AllQuery;
650650
use crate::schema::OwnedValue;
651651

@@ -774,7 +774,7 @@ mod tests {
774774
#[test]
775775
fn test_top_hits_collector_single_feature() -> crate::Result<()> {
776776
let docs = vec![
777-
ComparableDoc::<_, _, false> {
777+
ComparableDoc::<_, _> {
778778
doc: crate::DocAddress {
779779
segment_ord: 0,
780780
doc_id: 0,

src/aggregation/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ mod date;
139139
mod error;
140140
pub mod intermediate_agg_result;
141141
pub mod metric;
142-
mod top_n_computer;
143142

144143
mod segment_agg_result;
145144
use std::fmt::Display;

src/aggregation/top_n_computer.rs

Lines changed: 0 additions & 213 deletions
This file was deleted.

src/collector/filter_collector_wrapper.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ use crate::{DocId, Score, SegmentReader};
5050
///
5151
/// let query_parser = QueryParser::for_index(&index, vec![title]);
5252
/// let query = query_parser.parse_query("diary")?;
53-
/// let no_filter_collector = FilterCollector::new("price".to_string(), |value: u64| value > 20_120u64, TopDocs::with_limit(2));
53+
/// let no_filter_collector = FilterCollector::new("price".to_string(), |value: u64| value > 20_120u64, TopDocs::with_limit(2).order_by_score());
5454
/// let top_docs = searcher.search(&query, &no_filter_collector)?;
5555
///
5656
/// assert_eq!(top_docs.len(), 1);
5757
/// assert_eq!(top_docs[0].1, DocAddress::new(0, 1));
5858
///
59-
/// let filter_all_collector: FilterCollector<_, _, u64> = FilterCollector::new("price".to_string(), |value| value < 5u64, TopDocs::with_limit(2));
59+
/// let filter_all_collector: FilterCollector<_, _, u64> = FilterCollector::new("price".to_string(), |value| value < 5u64, TopDocs::with_limit(2).order_by_score());
6060
/// let filtered_top_docs = searcher.search(&query, &filter_all_collector)?;
6161
///
6262
/// assert_eq!(filtered_top_docs.len(), 0);
@@ -224,7 +224,7 @@ where
224224
///
225225
/// let query_parser = QueryParser::for_index(&index, vec![title]);
226226
/// let query = query_parser.parse_query("diary")?;
227-
/// let filter_collector = BytesFilterCollector::new("barcode".to_string(), |bytes: &[u8]| bytes.starts_with(b"01"), TopDocs::with_limit(2));
227+
/// let filter_collector = BytesFilterCollector::new("barcode".to_string(), |bytes: &[u8]| bytes.starts_with(b"01"), TopDocs::with_limit(2).order_by_score());
228228
/// let top_docs = searcher.search(&query, &filter_collector)?;
229229
///
230230
/// assert_eq!(top_docs.len(), 1);

src/collector/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
//! # let query_parser = QueryParser::for_index(&index, vec![title]);
5858
//! # let query = query_parser.parse_query("diary")?;
5959
//! let (doc_count, top_docs): (usize, Vec<(Score, DocAddress)>) =
60-
//! searcher.search(&query, &(Count, TopDocs::with_limit(2)))?;
60+
//! searcher.search(&query, &(Count, TopDocs::with_limit(2).order_by_score()))?;
6161
//! # Ok(())
6262
//! # }
6363
//! ```
@@ -99,6 +99,7 @@ mod multi_collector;
9999
pub use self::multi_collector::{FruitHandle, MultiCollector, MultiFruit};
100100

101101
mod top_collector;
102+
pub use self::top_collector::ComparableDoc;
102103

103104
mod top_score_collector;
104105
pub use self::top_score_collector::{TopDocs, TopNComputer};

src/collector/multi_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<TFruit: Fruit> FruitHandle<TFruit> {
152152
/// let searcher = reader.searcher();
153153
///
154154
/// let mut collectors = MultiCollector::new();
155-
/// let top_docs_handle = collectors.add_collector(TopDocs::with_limit(2));
155+
/// let top_docs_handle = collectors.add_collector(TopDocs::with_limit(2).order_by_score());
156156
/// let count_handle = collectors.add_collector(Count);
157157
/// let query_parser = QueryParser::for_index(&index, vec![title]);
158158
/// let query = query_parser.parse_query("diary").unwrap();

0 commit comments

Comments
 (0)