For #1. Unfortunately, there isn't a tool that's publicly available that would allow you to delete the entire search index. If you need to do that, please open up a support case and we should be able to help you with that. However, there is a way to use templates to delete based on a query that may help. See my comments below.
For #2. Please feel free to open a support case for deleting a specific orphaned item in the index as well. However, if you do need some control on your end, what you could do is create a dummy template that includes the following code in the search_g2_insert.aspx and search_g2_update.aspx template files. You'll need to assign this template to a dummy asset as well since the search_g2_insert.aspx and serach_g2_update.aspx template files execute on a publish.
var doc = new SearchG2JsonParams();
doc.Id = "<id here>";
doc.Operation = SearchG2JsonParams.OperationType.Delete;
context.JsonParams.Add(doc);
You'll need to replace <id here> with the id you're looking to delete. As mentioned you can also delete based off of a query with the following:
var doc = new SearchG2JsonParams();
doc.Query = "custom_s_test:\"cptest\"";
doc.Operation = SearchG2JsonParams.OperationType.Delete;
context.JsonParams.Add(doc);
The query assigned to the doc.Query property should be similar to the Solr Query syntax used to query the collection.
--
Edward ChanSr Product Consultant
## If I’ve helped, accept this response as a solution so that other’s can find is more quickly in the future.
## Have thoughts on Crownpeak products? We'd love to hear them. Speak with the Crownpeak Product Team..