Symptoms
- The assistant answers "I couldn't find information about that" for questions it handled yesterday.
- Retrieval returns zero or very few chunks; citations are missing.
- The document count in the index dropped sharply after a scheduled or manual sync.
- Often right after a storage change: a new bucket or prefix, a lifecycle rule, a permission change, or a pipeline deploy.
Most sync tools mirror the source. If the source looks empty, a full sync can delete everything that "disappeared". The index did what it was told. The fix is to stop the mirror, fix the source, then sync again.
1. Confirm scope and impact
Count documents in the index now and compare with your baseline.
# Azure AI Search
curl -s "https://srch-prod.search.windows.net/indexes/docs/docs/\$count?api-version=2024-07-01" \
-H "api-key: $SEARCH_KEY"
-- pgvector or any SQL-backed store
SELECT source, count(*) FROM rag_chunks GROUP BY source ORDER BY 2 DESC;
For Bedrock Knowledge Bases, the ingestion job statistics show exactly what the last sync did:
KB=ABCDEFGHIJ; DS=KLMNOPQRST
aws bedrock-agent list-ingestion-jobs --knowledge-base-id $KB --data-source-id $DS \
--sort-by attribute=STARTED_AT,order=DESCENDING --max-results 5 \
--query "ingestionJobSummaries[].{id:ingestionJobId, status:status, started:startedAt, stats:statistics}"
aws bedrock-agent get-ingestion-job --knowledge-base-id $KB --data-source-id $DS \
--ingestion-job-id <job-id> --query "ingestionJob.statistics"
A large numberOfDocumentsDeleted with a small numberOfDocumentsScanned confirms this incident.
Now look at the source itself:
aws s3 ls s3://kb-docs-prod/policies/ --recursive --summarize | tail -2
az storage blob list --account-name stdocsprod --container-name policies --auth-mode login \
--query "length(@)"
| Source looks like | Likely cause |
|---|---|
| Empty or nearly empty | Objects deleted (lifecycle rule, cleanup script, failed copy) |
| Full, but under a different prefix or container | Data source config or IaC points at the wrong path |
| Full, but the sync identity gets AccessDenied | Permission or key change; connector saw nothing |
| Full and correct | Pipeline bug ("delete all then reload" failed half-way) or index recreated |
2. Stop further damage
Pause every sync before you touch anything else. Another run against a broken source will delete whatever is left, or delete what you just restored.
# Bedrock KB syncs are usually triggered by EventBridge or a scheduled Lambda
aws events disable-rule --name kb-docs-nightly-sync
# Azure AI Search: disable the indexer schedule (get, set disabled, put back)
curl -s "https://srch-prod.search.windows.net/indexers/docs-indexer?api-version=2024-07-01" -H "api-key: $SEARCH_KEY" \
| jq 'del(."@odata.context", ."@odata.etag") | .disabled = true' > ixr.json
curl -s -X PUT "https://srch-prod.search.windows.net/indexers/docs-indexer?api-version=2024-07-01" \
-H "api-key: $SEARCH_KEY" -H "Content-Type: application/json" -d @ixr.json -o /dev/null -w "%{http_code}\n"
For custom pipelines, pause the Airflow DAG, disable the Function timer, or scale the worker to zero.
If the assistant is giving confident wrong answers without context, switch it to a safe message ("Search is temporarily unavailable") with your feature flag until the index is back.
3. Restore the source data
S3 with versioning
Deleted objects in a versioned bucket have a delete marker on top. Removing the marker brings the object back.
aws s3api list-object-versions --bucket kb-docs-prod --prefix policies/ \
--query 'DeleteMarkers[?IsLatest==`true`].[Key,VersionId]' --output text > markers.txt
wc -l markers.txt # check the count matches what you expect before deleting markers
while read -r key vid; do
aws s3api delete-object --bucket kb-docs-prod --key "$key" --version-id "$vid"
done < markers.txt
Caution
Only remove delete markers you have reviewed. Some deletions may be intentional (withdrawn policies, documents removed for legal reasons). Filter
markers.txtby time or prefix and get the content owner to confirm before restoring everything.
Azure Blob with soft delete
az storage blob list --account-name stdocsprod --container-name policies --auth-mode login \
--include d --query "[?deleted].name" -o tsv > deleted.txt
while read -r name; do
az storage blob undelete --account-name stdocsprod --container-name policies --name "$name" --auth-mode login
done < deleted.txt
Wrong path or permissions
If the data was never deleted, fix the data source configuration or the role instead:
aws bedrock-agent get-data-source --knowledge-base-id $KB --data-source-id $DS \
--query "dataSource.dataSourceConfiguration"
Compare the bucket and inclusion prefixes with what IaC intended. Test the sync role can list and read the path before re-running.
If there is no versioning or soft delete, restore from your backup or re-export from the system of record. That is the slow path; tell stakeholders now.
4. Re-ingest and verify
Run one sync manually and watch it:
aws bedrock-agent start-ingestion-job --knowledge-base-id $KB --data-source-id $DS \
--query "ingestionJob.ingestionJobId" --output text
curl -s -X POST "https://srch-prod.search.windows.net/indexers/docs-indexer/run?api-version=2024-07-01" -H "api-key: $SEARCH_KEY"
Check:
- Index document count back near the baseline.
numberOfDocumentsDeletednear zero on the recovery run.- Your top 20 real questions return the right sources (run the golden set if you have one).
Then re-enable the schedule.
Tip
In Azure AI Search, blob indexers do not remove index documents when blobs disappear unless you configured a deletion detection policy (for example native blob soft delete). If documents vanished from an Azure AI Search index, look at the pipeline or at an index recreate before blaming the indexer.
Communicate
"Since
Prevent it next time
Add a delete guard to any pipeline you control. Abort the run if it would remove more than a set share of the index:
def guard_sync(current_ids: set[str], source_ids: set[str], max_delete_ratio: float = 0.10):
to_delete = current_ids - source_ids
if not source_ids:
raise RuntimeError("Source returned 0 documents; refusing to sync")
if current_ids and len(to_delete) / len(current_ids) > max_delete_ratio:
raise RuntimeError(f"Sync would delete {len(to_delete)} of {len(current_ids)} docs; needs approval")
return to_delete
- Enable S3 versioning or Blob soft delete (with a retention long enough to notice) on every RAG source.
- Alert when the index document count drops more than 10% between runs, and on ingestion jobs with high delete counts.
- Separate "sync" and "full rebuild" jobs; only the rebuild may delete, and it needs a manual approval.
- Review lifecycle rules on RAG buckets and containers; they should never expire source documents.
- Keep data source paths in IaC and test changes against a non-production knowledge base first.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get