You can delete documents in FlexSearch in two ways:
- By submitting the HTTP request yourself (using a tool like Fiddler, for example)
For demonstration purposes, let’s delete an existing document with ID “7” from the index named contact.
Deleting documents using the C# client
First you need to get hold of an API that has the
DeleteDocument web service method. You can use either the
CommonApi or the
var documentsApi = new DocumentsApi("http://localhost:9800");
After initializing the C# client, we just need to call the
DeleteDocument method supplying the index name and the document ID that we want to delete.
The response doesn’t contain any data, it just contains the
var response = documentsApi.DeleteDocument("contact", "7"); // This method doesn't return any significant data. It just reports any errors. if (response.Error?.Message != null) Console.WriteLine(response.Error.Message);
Deleting documents by writing the HTTP request ourselves
Please have a look at the REST documentation for Document Management APIs.