You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect it to return snippets around the matched fuzzy terms.
Which version of tantivy are you using? 4aa8cd247
To Reproduce
I wrote the following test case in snippet/mod.rs (based on test_snippet_generator):
#[test]fntest_snippet_generator_with_fuzzy_field() -> crate::Result<()>{letmut schema_builder = Schema::builder();let text_options = TextOptions::default().set_indexing_options(TextFieldIndexing::default().set_tokenizer("en_stem").set_index_option(IndexRecordOption::Basic),);let text_field = schema_builder.add_text_field("text", text_options);let schema = schema_builder.build();let index = Index::create_in_ram(schema);{// writing the segmentletmut index_writer = index.writer_for_tests()?;let doc = doc!(text_field => TEST_TEXT);
index_writer.add_document(doc)?;
index_writer.commit()?;}let searcher = index.reader().unwrap().searcher();letmut query_parser = QueryParser::for_index(&index,vec![text_field]);
query_parser.set_field_fuzzy(text_field,false,1,true);// <--------------- THIS LINE ADDED <----let query = query_parser.parse_query("rust design").unwrap();letmut snippet_generator =
SnippetGenerator::create(&searcher,&*query, text_field).unwrap();{let snippet = snippet_generator.snippet(TEST_TEXT);assert_eq!(
snippet.to_html(),"imperative-procedural paradigms. <b>Rust</b> is syntactically similar to \ C++[according to whom?],\nbut its <b>designers</b> intend it to provide better \ memory safety");}{
snippet_generator.set_max_num_chars(90);let snippet = snippet_generator.snippet(TEST_TEXT);assert_eq!(
snippet.to_html(),"<b>Rust</b> is syntactically similar to C++[according to whom?],\nbut its \ <b>designers</b> intend it to");}Ok(())}
Output is:
---- snippet::tests::test_snippet_generator_with_fuzzy_field stdout ----
thread 'snippet::tests::test_snippet_generator_with_fuzzy_field' panicked at src/snippet/mod.rs:800:13:
assertion `left == right` failed
left: ""
right: "imperative-procedural paradigms. <b>Rust</b> is syntactically similar to C++[according to whom?],\nbut its <b>designers</b> intend it to provide better memory safety"
The text was updated successfully, but these errors were encountered:
Describe the bug
""
.Which version of tantivy are you using?
4aa8cd247
To Reproduce
I wrote the following test case in
snippet/mod.rs
(based ontest_snippet_generator
):Output is:
The text was updated successfully, but these errors were encountered: