Reputation: 6157
I have an Azure Search that indexes an Azure Storage every 5 minutes. Since the storage may also have deletes ocassionally I was looking for a way to handle those. From the documentation I understand that unless you manually delete an index or rebuild the index.
A full rebuild would do, but I would like to keep downtime to a minimum. I was looking for a strategy to do so. Right now I thought about building a second index that's build up and once it's done delete the old one; It however feels a bit clumsy as I would have to keep track of the index names.
Right now it looks like this (simplified):
//create new index
searchClient.Indexes.CreateOrUpdate(index);
//update indexer
var indexer = searchClient.Indexers.Get("testindexer");
indexer.TargetIndexName = index.Name;
searchClient.Indexers.CreateOrUpdate(indexer.Name);
//reset and run indexer
searchClient.Indexers.Reset(indexer.Name);
searchClient.Indexers.Run(indexer.Name);
//at this point the new index is used
//delete old index
searchClient.Indexes.Delete(oldIndex.Name);
Upvotes: 0
Views: 1066
Reputation: 884
There is documentation for recommended practices on reindexing data similar to the scenario that you mention that may be useful. In addition, if you would like Azure Search to support a data deletion policy for hard deletions in the future, there is an uservoice request that you can vote on here. As the other answer mentions, the recommended policy for this today is using the soft delete option that Azure Search provides, so if you can restructure how your deletes are done then that would be a potential option as well.
Upvotes: 1
Reputation: 395
From the documentation it looks like incremental indexing is enabled for you by default: https://learn.microsoft.com/en-us/azure/search/search-howto-indexing-azure-blob-storage
Additionally you can use "soft delete" option in case those deleted files might reappear at some point.
Upvotes: 1