iQ Suite - Docs
SDK ReferenceDocument RAG

Add Document to Index with Polling

Add a new document to an existing index and monitor the addition process until completion using polling.

Description

The Add Document to Index with Polling endpoint allows you to expand an existing searchable index by uploading additional documents. Supported file types include PDF, DOC, DOCX, PPT, PPTX with a maximum file size of 20MB. This operation is asynchronous, and polling is used to monitor its progress until completion.

Caution

Add Document to Index with Polling with polling is an synchronous process and it'll run until the index creation is completed and it can take upto 300 seconds to complete depending upon the size of the uploaded file.

It's recommended to use our Webhooks or putting this method inside an async queue.

Request Example

try:
    with open('document.pdf', 'rb') as file:
        response, status = client.add_document_and_poll(
            index_id='your_index_id',
            document=file,               # Pass the binary file object
            filename='document.pdf',     # Provide the filename
            poll_interval=20,            # Time in seconds between each poll
            max_retries=10               # Maximum number of polling attempts
        )
 
    document_id = getattr(status, 'document_id', None)
 
    print("Document indexing completed")
    print(f"Status Details: {status}")
        
except APIError as e:
    print(f"An API error occurred while adding the document: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

On this page