Beispiel #1
0
def test_search_ids():
    kiri = Kiri(local=True)
    docs = get_docs()
    docs[0].id = "123"
    kiri.upload(docs)
    results = kiri.search("another", ids=["123"])
    assert len(results.results) == 1, "Invalid number of search results"
Beispiel #2
0
                                doc_class=ElasticChunkedDocument,
                                index="kiri_default")
    docs = [d["elastic"] for d in tech_docs]
else:
    doc_store = InMemoryDocStore(doc_class=ChunkedDocument)
    docs = [d["memory"] for d in tech_docs]

kiri = Kiri(doc_store, local=True)
kiri.upload(docs)

query = ""
if len(argv) == 1:
    print("Supply a query when running this script")
    print("Usage: python doc_search.py \"<your query here>\"")
    exit(0)
elif len(argv) == 2:
    query = argv[1]
else:
    query = " ".join(argv[1:])

print(f"Query: {query}")

results = kiri.search(query, max_results=3, min_score=0.01)

print("Total results:", results.total_results)
for result in results.results:
    # Can add any attributes you like to a doc
    print(result.document.attributes["title"])
    print(result.preview)
    print("Score: " + str(result.score))
    print("========")
Beispiel #3
0
def test_search_max_results_chunk():
    kiri = Kiri(local=True)
    docs = get_chunked_docs()
    kiri.upload(docs)
    results = kiri.search("another", max_results=1)
    assert len(results.results) == 1, "Invalid number of search results"
Beispiel #4
0
def test_search():
    kiri = Kiri(local=True)
    docs = get_docs()
    kiri.upload(docs)
    results = kiri.search("another")
    assert len(results.results) == 2, "Invalid number of search results"