Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide
GitHubNuGetDev CommunityOptimizely AcademySubmit a ticket

Optimizely developer documentation

How can we help you?

Try our conversational search powered by Generative AI!

AI OnAI Off

Delete documents from an index

Describes how to delete documents from an index, using the Client interface in the .NET Client API for Optimizely Search & Navigation.

Delete a document

You can delete individual documents from the index using the IClient interface's Delete method. For example, the code below deletes a BlogPost with ID 42.

client.Delete<BlogPost>(42);

Delete multiple documents by filter

You can delete documents that match the criteria defined in a filter expression. For example, the code below deletes documents of type BlogPost, and those of a type inheriting from BlogPost that are tagged with "Banana."

client.Delete<BlogPost>(x => x.Tags.Match("Banana"));

You can also delete documents that match criteria defined in a filter expression and on multiple fields. The code below deletes documents of type BlogPost, and those of a type inheriting from BlogPost that are tagged with "Banana" and whose author name contains "Fredrik."

client.Delete<BlogPost>(x => x.Tags.Match("Banana") & x.Name.Match("Fredrik"))

Delete documents from the recycle bin

When deleting documents from the recycle bin, make sure that you only delete if a document returns shouldIndex=true for CheckPublishedStatus && DisableIndexing. In this way, you avoid many 404 errors when Optimizely Search & Navigation tries to delete an unindexed document from the recycle bin.


Did this page help you?