Skip to content

Commit

Permalink
Backport new docs feature to tantivy v0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
calyptobai authored and anastasiya1155 committed Apr 9, 2024
1 parent d905c58 commit 4b70f5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions server/bleep/src/collector/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ impl Collector for GroupCollector {
segment_local_id: u32,
segment_reader: &SegmentReader,
) -> tantivy::Result<GroupSegmentCollector> {
let field_name = segment_reader.schema().get_field_name(self.field);
let fast_field_reader = segment_reader.fast_fields().bytes(field_name)?.unwrap();
let fast_field_reader = segment_reader.fast_fields().bytes(self.field)?;
Ok(GroupSegmentCollector {
fast_field_reader,
segment_local_id,
Expand Down Expand Up @@ -107,7 +106,7 @@ impl Collector for GroupCollector {
}

pub struct GroupSegmentCollector {
fast_field_reader: tantivy_columnar::BytesColumn,
fast_field_reader: tantivy::fastfield::BytesFastFieldReader,
segment_local_id: u32,
groups: Groups,
group_size: usize,
Expand All @@ -117,15 +116,7 @@ impl SegmentCollector for GroupSegmentCollector {
type Fruit = Option<Groups>;

fn collect(&mut self, doc: u32, _score: Score) {
let mut value = Vec::new();
self.fast_field_reader
.ords()
.values_for_doc(doc)
.for_each(|ord| {
self.fast_field_reader
.ord_to_bytes(ord, &mut value)
.unwrap();
});
let value = self.fast_field_reader.get_bytes(doc);
let hash = blake3::hash(&value);
let entry = self.groups.items.entry(hash).or_default();
if entry.items.len() < self.group_size {
Expand Down
2 changes: 1 addition & 1 deletion server/bleep/src/indexes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl Doc {

section_index
.tokenizers()
.register("trigram", NgramTokenizer::new(1, 3, false).unwrap());
.register("trigram", NgramTokenizer::new(1, 3, false));

Ok(Self {
sql,
Expand Down

0 comments on commit 4b70f5c

Please sign in to comment.