Home » How to Show Document Indexing Progress in a React RAG Application
React • Technology • Top companies

How to Show Document Indexing Progress in a React RAG Application

Build a status UI that distinguishes file upload, indexing, and search readiness, then reuse the same API in React Native.

A user uploads a 100-page PDF. The upload bar reaches 100%, so they ask a question about the document. The app returns an answer without using the PDF because the backend is still generating embeddings. From the user’s point of view, the app accepted the file and ignored it.

In a retrieval-augmented generation (RAG) app, upload complete, indexing complete, and ready to search are separate milestones. The frontend should show which milestone the backend has actually reached. That distinction matters with managed services too. AWS documents that for vector stores other than Amazon Aurora, newly ingested embeddings can take a few minutes to become queryable after a Bedrock ingestion job completes. 

1. Give React a status API it can trust

Once the upload is verified, queue an indexing job and return its ID. The worker should persist status independently of the browser or mobile app. That lets a user refresh the page, reopen the app, or switch devices and see the same job.

A practical API has two endpoints:

  • POST /api/documents/:documentId/indexing-jobs queues an attempt and returns 202 Accepted with a jobId.
  • GET /api/indexing-jobs/:jobId returns the latest status. The server checks that the caller can access the document and its workspace.

A response during embedding might look like this:

{
  "state": "running",
  "stage": "embedding",
  "progress": {
    "completed": 84,
    "total": 120
  }
}

In this contract, progress describes chunks completed in the current stage. The UI can say “Embedding 84 of 120 chunks.” It has enough information to report progress for embedding, with parsing and search verification tracked separately. If the worker has yet to count the chunks, return progress: null.

Worker state or stageWhat the user seesWhen to use it
queuedWaiting to startThe job has been accepted
parsingReading documentText extraction or OCR is underway
embeddingEmbedding 84 of 120 chunksThe worker has a reliable chunk count
indexingAdding to search indexThe worker is writing chunks to the index
verifyingChecking search availabilityWrites are complete and retrieval readiness is being checked
readyReady to ask questionsThe active document version is available to retrieval
failedCouldn’t index this documentThe attempt ended and needs a retry or user action
cancelledIndexing cancelledThe server has confirmed cancellation

Treat ready as a promise about the application’s retrieval path. Use the provider’s documented readiness guarantee when it covers that path. If visibility can lag, verify retrieval using the same workspace, document ID, and version filters the RAG application uses. Otherwise, an older version of the document can make the check pass.

2. Poll from React and stop when the job ends

For a document details screen, polling is a straightforward starting point. The example below assumes TanStack Query v5 and a QueryClientProvider already configured. It starts with a two-second interval for illustration. Tune it against the number of active jobs and the update frequency users actually need. TanStack Query supports a dynamic refetchInterval, so the query can stop polling once it sees a terminal state. 

import { useQuery } from '@tanstack/react-query';

type IndexingJob = {
  state: 'queued' | 'running' | 'ready' | 'failed' | 'cancelled';
  stage: 'parsing' | 'embedding' | 'indexing' | 'verifying' | null;
  progress: { completed: number; total: number } | null;
};

const terminalStates = new Set(['ready', 'failed', 'cancelled']);

const stageLabels = {
  parsing: 'Reading document',
  embedding: 'Generating embeddings',
  indexing: 'Adding to search index',
  verifying: 'Checking search availability',
};

export function DocumentIndexingStatus({ jobId }: { jobId: string }) {
  const job = useQuery({
    queryKey: ['indexing-job', jobId],
    queryFn: async ({ signal }): Promise<IndexingJob> => {
      const response = await fetch(
        `/api/indexing-jobs/${encodeURIComponent(jobId)}`,
        { signal, cache: 'no-store' },
      );

      if (!response.ok) throw new Error('Could not refresh indexing status');
      return response.json();
    },
    retry: 1,
    refetchInterval: ({ state }) => {
      if (state.error || terminalStates.has(state.data?.state ?? '')) {
        return false;
      }
      return 2_000;
    },
  });

  const snapshot = job.data;
  const active = snapshot?.state === 'queued' || snapshot?.state === 'running';
  const progress = snapshot?.progress;
  const measured = progress && progress.total > 0 ? progress : null;

  let label = 'Checking indexing status';
  if (snapshot?.state === 'queued') label = 'Waiting to start';
  if (snapshot?.state === 'running' && snapshot.stage) {
    label = stageLabels[snapshot.stage];
  }
  if (snapshot?.state === 'ready') label = 'Ready to ask questions';
  if (snapshot?.state === 'failed') label = 'Couldn’t index this document';
  if (snapshot?.state === 'cancelled') label = 'Indexing cancelled';

  return (
    <section aria-label="Document indexing">
      <p role="status">{label}</p>

      {active && (
        <progress
          aria-label={label}
          max={measured?.total ?? 1}
          value={measured?.completed}
        />
      )}

      {active && measured && (
        <p>{measured.completed} of {measured.total} chunks</p>
      )}

      {job.isError && (
        <>
          <p>Couldn’t refresh status. Any status shown may be out of date.</p>
          <button onClick={() => void job.refetch()}>Refresh status</button>
        </>
      )}
    </section>
  );
}

When the total is unknown, the <progress> element has no value and displays indeterminate progress. The status text announces stage changes, while the chunk count remains separately available. A failed status request displays a refresh action because a lost connection says nothing about whether the indexing worker is still running. 

3. Reuse the status contract in React Native

Keep the job types, terminal states, and polling logic shared. The mobile client can call the same endpoint using an absolute API URL and the app’s authenticated HTTP client. Use React Native’s AppState with TanStack Query’s focusManager to pause interval polling in the background and refresh stale status when the app becomes active. Once the upload has reached the server, indexing can continue even if the user closes the app. 

For the native UI, use an ActivityIndicator with a stage label when the total is unknown. For measured progress, expose accessibilityRole="progressbar" and an accessibilityValue with min, now, and max. Keep the document or job ID in the app’s durable state so reopening the screen can recover the latest status. 

How five companies approach ingestion and progress

CompanyWhat its public documentation showsWhat React teams can apply
GeekyAntsIts public RAG materials describe document retrieval pipelines. Its Report Intelligence Accelerator separately documents upload, validation results, and generation status in a related workflow. The public materials do not specify a React document-indexing progress UI. Apply the documented workflow pattern to RAG by exposing upload, validation, processing, and readiness as distinct user-facing states.
MicrosoftAzure AI Search exposes per-run itemsProcessed, itemsFailed, errors, and warnings. A run can succeed even when some items fail, depending on the configured threshold.Show the run outcome and the document outcomes separately.
Amazon Web ServicesBedrock exposes ingestion job statistics for scanned, newly indexed, modified, skipped, and failed documents. AWS also documents a potential delay before new embeddings are queryable. Treat “scanned” as a scan count and distinguish job completion from search availability.
Google CloudRAG Engine reports imported, failed, and skipped files. Its documentation explains that a previously imported file can be skipped when the file and chunking configuration are unchanged.Give an unchanged document its own outcome, such as “Already up to date.”
OpenAIIts vector store file batch API exposes batch status and file counts for completed, failed, cancelled, and in-progress files.Show file outcomes in bulk uploads. Keep the failed count visible when the batch ends.

Test the cases a demo usually skips

  • Scanned or password-protected PDF. Show “Reading document” while OCR is underway. If extraction ends without usable text, explain what the user can change before retrying.
  • Partial batch failure. If 9 of 10 documents are ready, say so and identify the one that failed. Retry that document without duplicating the nine successful records.
  • A new version of an existing document. Keep the current version available while the replacement indexes, then switch the active version once the new one is retrievable.
  • A phone goes offline during indexing. Keep the last known state visible, label it as stale if a refresh fails, and reconcile it with the server when the app reconnects.

The most useful status is the one that tells the user what they can do next. A chunk count explains why indexing is taking time. “Ready to ask questions” tells the user when the document can actually inform an answer.