README: Update the docs for the new simpler search API.

master
Damir Jelić 2020-01-05 17:22:58 +01:00
parent 62d87119fa
commit 32b6b67af4
2 changed files with 3 additions and 6 deletions

View File

@ -50,9 +50,8 @@ writer.commit()
index.reload()
searcher = index.searcher()
query = index.parse_query("fish days", ["title", "body"])
top_docs = tantivy.TopDocs(3)
(best_score, best_doc_address) = searcher.search(query, top_docs)[0]
(best_score, best_doc_address) = searcher.search(query, 3).hits[0]
best_doc = searcher.doc(best_doc_address)
assert best_doc["title"] == ["The Old Man and the Sea"]
print(best_doc)

View File

@ -61,11 +61,9 @@ use searcher::{DocAddress, Searcher};
/// >>> reader = index.reader()
/// >>> searcher = reader.searcher()
///
/// >>> query_parser = tantivy.QueryParser.for_index(index, [title, body])
/// >>> query = query_parser.parse_query("sea whale")
/// >>> query = index.parse_query("sea whale", [title, body])
///
/// >>> top_docs = tantivy.TopDocs.with_limit(10)
/// >>> result = searcher.search(query, top_docs)
/// >>> result = searcher.search(query, 10)
///
/// >>> assert len(result) == 1
///