Skip to content

Commit

Permalink
Merge 28d64ff into 0472424
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Jun 11, 2021
2 parents 0472424 + 28d64ff commit b9a437f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ pub fn add_document_to_index<T: Eq + Hash + Copy, D>(
let mut filtered_terms_count = 0;
for mut term in terms {
term = filter(&term);
all_terms.push(term.to_owned());
if term.as_str() != "" {
all_terms.push(term.to_owned());
filtered_terms_count += 1;
let counts = term_counts.get_mut(&term);
match counts {
Expand Down Expand Up @@ -606,6 +606,26 @@ mod tests {

// dont test all the properties
}

#[test]
fn it_should_empty_tokens() {
let field_accessors: Vec<FieldAccessor<Doc>> =
vec![field_accessor as fn(doc: &Doc) -> Option<&str>];

let mut index = create_index::<usize>(1);
let doc_1 = Doc {
id: 1,
text: "a b".to_string(), // double space could introduce empty tokens
};
add_document_to_index(
&mut index,
&field_accessors,
tokenizer,
filter,
doc_1.id,
doc_1.clone(),
);
}
}

mod delete {
Expand Down

0 comments on commit b9a437f

Please sign in to comment.