You can also register deletion of multiple files that match certain criteria. Then the actual delete operation is performed based on
results of the specified query. There are two methods accessible from the session that allows you to pass the query that will be used to determine
which files have to be deleted.
The first one is
RegisterDeletionQuery, which has the following signature:
void RegisterDeletionQuery(string query);
||The Lucene query
You need to specify the valid Lucene query as a string value.
The below code deletes all files which names end with
.draft (note the usage of the built-in
__rfileName term, click here to see more built-in index fields)
Deleting multiple files by querying is even more convenient when you can take advantage of the session's querying support.
The below code registers exactly the same files for deletion, in this case however the query is specified in strongly typed manner:
.WhereEndsWith(x => x.Name, ".draft")