Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langgenius Dify FetchIndexingStatus

From Leeroopedia
Revision as of 11:27, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Langgenius_Dify_FetchIndexingStatus.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources Domains Last Updated
Dify RAG, Knowledge_Management, Frontend 2026-02-12 00:00 GMT

Overview

Description

fetchIndexingStatus and fetchIndexingStatusBatch are frontend service functions that retrieve the current processing state of documents being indexed in a Dify knowledge base. fetchIndexingStatus returns the status of a single document, while fetchIndexingStatusBatch returns the status of all documents in a given batch.

These functions are typically called in a polling loop after document upload to drive progress indicators and detect terminal states (completed or error).

Usage

  • Poll fetchIndexingStatus at regular intervals (e.g., every 2--5 seconds) after calling createDocument to track a single document through the pipeline.
  • Use fetchIndexingStatusBatch when multiple documents were uploaded together, using the batch ID from the createDocumentResponse.
  • Stop polling when indexing_status reaches completed, error, or paused.

Code Reference

Source Location

web/service/datasets.ts, lines 148--154.

Signature

export const fetchIndexingStatus = (
  { datasetId, documentId }: CommonDocReq
): Promise<IndexingStatusResponse> => {
  return get<IndexingStatusResponse>(
    `/datasets/${datasetId}/documents/${documentId}/indexing-status`, {}
  )
}

export const fetchIndexingStatusBatch = (
  { datasetId, batchId }: BatchReq
): Promise<IndexingStatusBatchResponse> => {
  return get<IndexingStatusBatchResponse>(
    `/datasets/${datasetId}/batch/${batchId}/indexing-status`, {}
  )
}

Import

import { fetchIndexingStatus, fetchIndexingStatusBatch } from '@/service/datasets'

I/O Contract

Inputs

fetchIndexingStatus:

Parameter Type Required Description
datasetId string Yes The ID of the dataset containing the document.
documentId string Yes The ID of the document to check.

fetchIndexingStatusBatch:

Parameter Type Required Description
datasetId string Yes The ID of the dataset containing the batch.
batchId string Yes The batch identifier returned from document creation.

Outputs

fetchIndexingStatus returns Promise<IndexingStatusResponse>:

Field Type Description
id string Document identifier.
indexing_status DocumentIndexingStatus Current status: waiting, parsing, cleaning, splitting, indexing, paused, error, or completed.
processing_started_at number Unix timestamp when processing began.
parsing_completed_at number Unix timestamp when parsing finished.
cleaning_completed_at number Unix timestamp when cleaning finished.
splitting_completed_at number Unix timestamp when splitting finished.
completed_at any Unix timestamp when indexing completed (null if not yet complete).
paused_at any Unix timestamp when processing was paused (null if not paused).
error any Error details if status is error (null otherwise).
stopped_at any Unix timestamp when processing was stopped (null otherwise).
completed_segments number Number of segments that have been indexed so far.
total_segments number Total number of segments to be indexed.

fetchIndexingStatusBatch returns Promise<IndexingStatusBatchResponse>:

Field Type Description
data IndexingStatusResponse[] Array of status records, one per document in the batch.

Usage Examples

Polling a single document until completion

import { fetchIndexingStatus } from '@/service/datasets'

async function pollUntilComplete(datasetId: string, documentId: string) {
  const POLL_INTERVAL = 3000 // 3 seconds
  let status = await fetchIndexingStatus({ datasetId, documentId })

  while (status.indexing_status !== 'completed' && status.indexing_status !== 'error') {
    await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL))
    status = await fetchIndexingStatus({ datasetId, documentId })

    const progress = status.total_segments > 0
      ? Math.round((status.completed_segments / status.total_segments) * 100)
      : 0
    console.log(`Status: ${status.indexing_status}, Progress: ${progress}%`)
  }

  if (status.indexing_status === 'error') {
    console.error('Indexing failed:', status.error)
  }
  return status
}

Monitoring a batch of documents

import { fetchIndexingStatusBatch } from '@/service/datasets'

const batchStatus = await fetchIndexingStatusBatch({
  datasetId: 'ds-abc123',
  batchId: 'batch-xyz789',
})

for (const doc of batchStatus.data) {
  console.log(`Document ${doc.id}: ${doc.indexing_status} (${doc.completed_segments}/${doc.total_segments})`)
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment