forked from milvus-io/tantivy
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
index_writer
.add_document(doc!(
doc_id => 1 as i64,
text => "alice and bob and carol dave"
))
.unwrap();
index_writer
.add_document(doc!(
doc_id => 2 as i64,
text => "bob"
))
.unwrap();
index_writer
.add_document(doc!(
doc_id => 3 as i64,
text => "bob"
))
.unwrap();
index_writer
.add_document(doc!(
doc_id => 4 as i64,
text => "carol"
))
.unwrap();
index_writer
.add_document(doc!(
doc_id => 5 as i64,
text => "dave"
))
.unwrap();
index_writer
.add_document(doc!(
doc_id => 6 as i64,
text => "dave"
))
.unwrap();
index_writer
.add_document(doc!(
doc_id => 7 as i64,
text => "dave"
))
.unwrap();
index_writer.commit().unwrap();
let reader = index.reader().unwrap();
let searcher = reader.searcher();
let mut terms = vec![];
let phrases = vec!["alice", "bob", "carol", "dave"];
for (idx, w) in phrases.iter().enumerate() {
terms.push((idx, Term::from_field_text(text, w)));
}
let query = PhraseQuery::new_with_offset_and_slop(terms, 2);
let res = searcher
.search(&query, &DocIdCollector::<u32>::default())
.unwrap();
The above example insert "alice and bob and carol dave", which should be searched by "alice bob carol dave" with slop 2. But it does not.
However, if all insertions are removed except the first one, the query can return the correct result.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels