dtSearch Remove Url Or Document From Index Using IndexJob
By Robbe Morris
It only takes a few lines of code to remove a url or document from a dtsearch index.
The documentation for dtSearch gives a very vague set of instructions for deleting
urls and files from an index. I really like dtsearch and we use it extensively
here at EggHeadCafe. However, their documentation is often vague and some aspects
of the API are not particularly clear.
Here's how you perform this simple task. Create a text file that contains one
url per line. Then set the ToRemoveListName property with the full path and filename.
The ActionRemoveListed = true tell the generic Execute method to remove these
urls from the index. The IndexJob will not throw an error if the url doesn't
exist in the index. So, if you have multiple indexes that you want to make absolutely
sure the offending url no longer exists, you are free to process the same url
list against many different dtsearch indexes.
using (var job = new IndexJob())
job.IndexPath = indexPath;
job.ActionRemoveListed = true;
job.ToRemoveListName = @"C:\MyUrlsToRemoveFromDtSearch.txt";
var success = job.Execute();
I would have preferred the API to have a method to remove documents. The property
ToRemoveListName is not an obvious property for a filename. Using a couple of
properties to drive the internal logic of a generic method named .Execute is
not clear to anyone. Just my 3 cents...
Add a file to a dtsearch index using IndexJob
dtSearch Remove Url Or Document From Index Using IndexJob (2265 Views)