You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/search/search-how-to-index-markdown-blobs.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -442,6 +442,45 @@ The resulting search document in the index would look as follows:
442
442
443
443
> [!NOTE]
444
444
> These examples specify how to use these parsing modes entirely with or without field mappings, but you can leverage both in one scenario if that suits your needs.
445
+
>
446
+
447
+
## Managing Stale Documents from Markdown Re-indexing
448
+
449
+
When working with Markdown files in Azure AI Search, it's important to understand how deletions are handled during re-indexing. The indexer does not automatically delete previously indexed documents when a file is modified or sections are removed. This can lead to duplicate or stale documents remaining in the index.
450
+
451
+
### Behavior overview
452
+
453
+
***No automatic deletion**: If sections are removed from a Markdown file and the file is re-indexed, the indexer will overwrite existing documents with new ones. However, it does not delete documents that no longer correspond to any content in the updated file.
454
+
***Potential for duplicates**: This behavior can result in duplicate documents, especially in `oneToMany` parsing mode where each section becomes a separate document. This issue typically arises only when more Markdown sections are deleted than inserted between indexing runs. In such cases, the index retains documents from the previous version that no longer match any current content, leading to stale entries.
455
+
### Workaround options
456
+
457
+
To ensure the index reflects the current state of your Markdown files, consider one of the following approaches:
458
+
459
+
#### Option 1. Use the delete API
460
+
461
+
Before re-indexing a modified Markdown file, explicitly delete the existing documents associated with that file using the https://learn.microsoft.com/en-us/rest/api/searchservice/delete-documents.
462
+
Steps:
463
+
464
+
1. Identify the id of the documents associated with the file. Use a query like the one below to retrieve the document IDs (e.g., `id`, `chunk_id`, etc.) for all documents tied to a specific file. Replace `metadata_storage_path` with the appropriate field in your index that maps to the file path or blob URI.
465
+
```
466
+
GET https://<search-service>.search.windows.net/indexes/<index-name>/docs?api-version=2025-05-01-preview
0 commit comments