After uploading some documents to your collection, you can start querying them. Below are some examples of how to do this using the ZeroEntropy SDK for Python and TypeScript.

Query for top k documents

In the examples/upload section, we uploaded a document with the text “My favorite apple is the Granny Smith.”.

from zeroentropy import ZeroEntropy
zclient = ZeroEntropy()

# Assume you have already added documents to the collection "default"
response = zclient.queries.top_documents(
    collection_name="default",
    query="What is the best apple?",
    k=1,
)

print(response.results)

Query for top k pages

In the examples/upload section, we uploaded a document with two pages of text about apples and search.

from zeroentropy import ZeroEntropy
z = ZeroEntropy()
# Assume you have already added documents to the collection "pages"
response = zclient.queries.top_pages(
    collection_name="pages",
    query="What is the best apple?",
    k=1,
    include_content=True,
)
print(response.results)

Query for top k snippets with metadata filtering

In the examples/upload section, we uploaded a pdf which was an arxiv paper about RAG evaluation in the “pdfs” collection. The pdf was uploaded with the metadata "arxiv" and "research".

from zeroentropy import ZeroEntropy
zclient = ZeroEntropy()

# Assume you have already added documents to the collection "pdfs"
response = zclient.queries.top_snippets(
    collection_name="pdfs",
    query="What is Retrieval Augemented Generation?",
    k=1,
    filter={
        "list:tags": {
            "$in": ["arxiv"]
        }
    },
    precise_responses=True,
)

print(response.results)

For more information on metadata filtering, see the metadata filtering section.