Search for docs

Document Search

search for document without a query

You can search for documents without a query, meaning you just use different parameters to display the desired selection of documents. To do that, simply follow the recipe below:

from recital.api.search import search_documents
from recital.models import search_query_string_query

query = search_query_string_query.SearchQueryStringQuery(keywords=["contract"], 
                                                         keyword_op="and",
                                                         folder_ids=[],
                                                         limit = 10
                                                        )

result = search_documents.sync(client=client, json_body=query)

for document in result.documents:
  print(document.name)

You can use the following parameters to refine your search:

  • filters: use previously applied metadata as filters
  • keywords: view it as a "ctrl + F", the string must be present at least once in the document
  • folders: restrict you search to one or multiple folders only
  • limit : you can specify the number of documents you want to be returned

search for documents with a query

You can perform a search within documents with a query. The result will be the documents containing the top chunk(s) returned from your query.To do that, simply follow the recipe below:

from recital.api.search import search_documents
from recital.models import search_query_string_query

query = search_query_string_query.SearchQueryStringQuery(query="my cool query",
                                                         keywords=[],
                                                         keyword_op="and", 
                                                         folder_ids=[]
                                                        )

result = search_documents.sync(client=client, json_body=query)
for doc in sd.result:
    print(doc.id)
    print(doc.num_pages)
    print(doc.name)
  • query: any input string (e.g: "age of the captain")

For those kind query, only the document with the best scores will be returned, there is no notion of exhaustivity.


Did this page help you?