README: Update the docs for the new simpler search API.
parent
62d87119fa
commit
32b6b67af4
|
@ -50,9 +50,8 @@ writer.commit()
|
||||||
index.reload()
|
index.reload()
|
||||||
searcher = index.searcher()
|
searcher = index.searcher()
|
||||||
query = index.parse_query("fish days", ["title", "body"])
|
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)
|
best_doc = searcher.doc(best_doc_address)
|
||||||
assert best_doc["title"] == ["The Old Man and the Sea"]
|
assert best_doc["title"] == ["The Old Man and the Sea"]
|
||||||
print(best_doc)
|
print(best_doc)
|
||||||
|
|
|
@ -61,11 +61,9 @@ use searcher::{DocAddress, Searcher};
|
||||||
/// >>> reader = index.reader()
|
/// >>> reader = index.reader()
|
||||||
/// >>> searcher = reader.searcher()
|
/// >>> searcher = reader.searcher()
|
||||||
///
|
///
|
||||||
/// >>> query_parser = tantivy.QueryParser.for_index(index, [title, body])
|
/// >>> query = index.parse_query("sea whale", [title, body])
|
||||||
/// >>> query = query_parser.parse_query("sea whale")
|
|
||||||
///
|
///
|
||||||
/// >>> top_docs = tantivy.TopDocs.with_limit(10)
|
/// >>> result = searcher.search(query, 10)
|
||||||
/// >>> result = searcher.search(query, top_docs)
|
|
||||||
///
|
///
|
||||||
/// >>> assert len(result) == 1
|
/// >>> assert len(result) == 1
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue