Fix explanation of boost queries seeking beyond query result. (#2142)

* Make current nightly Clippy happy.

* Fix explanation of boost queries seeking beyond query result.
This commit is contained in:
Adam Reichold
2023-08-14 04:59:11 +02:00
committed by GitHub
parent b92082b748
commit 22c35b1e00
6 changed files with 25 additions and 21 deletions

View File

@@ -221,5 +221,19 @@ fn main() -> tantivy::Result<()> {
println!("{}", schema.to_json(&retrieved_doc));
}
// We can also get an explanation to understand
// how a found document got its score.
let query = query_parser.parse_query("title:sea^20 body:whale^70")?;
let (_score, doc_address) = searcher
.search(&query, &TopDocs::with_limit(1))?
.into_iter()
.next()
.unwrap();
let explanation = query.explain(&searcher, doc_address)?;
println!("{}", explanation.to_pretty_json());
Ok(())
}