Search documents
Find which of your documents likely answer each question, without searching their pages: to choose which to search, or to show a person which documents to read.
found = client.search_documents("What was capital expenditure in 2018?", collection=reports, filter={"year": 2018})
for match in found["results"][0]["documents"]:
print(match["name"], match["relevance"])
What search_documents() returns, in Python:
{
"id": "srch_…",
"results": [
{"question": "What was capital expenditure in 2018?",
"documents": [{"id": "pi-cmwi3zsxk000109p6gspztvzb", "name": "3M_2018_10K.pdf", "pageNum": 160,
"folderId": null, "collectionId": "cmwi3zsj5000009p64s38ue3v",
"metadata": {"ticker": "MMM", "year": 2018}, "relevance": 0.9}],
"more_documents": […]}
],
"failed_documents": [],
"processing_documents": [],
"usage": {"documents": 40, "questions": 1, "billable_documents": 40, "credits": 1.2, "balance": 998.8},
"seconds": 0.35
}
- It takes the same scopes as a search of pages, except one document (see Search pages); pass a list of documents as
document_ids=, and a folder asfolder=folder_id, withrecursive=Truefor its subfolders too. - Each question lists the documents likely to help, most relevant first, each with its relevance. It may list none, when no document is likely to:
more_documentslists the next most relevant, up to 10, to look at if the question is worded unlike them. top_k: list exactly this many documents instead, the most relevant.- A document's file name and metadata count, so name and tag documents well (see Collections with metadata).
- Each document searched is priced as a document, whatever its length (see Pricing). With metadata, a filter that picks the documents out is free: list them instead.