RavenDB 4 - Dropping collections

39 views
Skip to first unread message

Fernando Ferreira Diniz de Moraes

unread,
Oct 16, 2017, 3:50:06 PM10/16/17
to RavenDB - 2nd generation document database
I searched for a similar question, but I couldn't find any topic discussing it.

Now that Raven/DocumentsByEntityName is gone, how can one delete a collection of documents? We've been using the following code to accomplish it:

private Operation InternalDropCollection<TDocument>()
{
 
var tag = _store.Conventions.GetTypeTagName(typeof(TDocument));
 
var operation = _store.DatabaseCommands.DeleteByIndex("Raven/DocumentsByEntityName", new IndexQuery { Query = "Tag:" + tag }, true);
 
return operation;
}

I've tried to use the most obvious code I could think of, on top of the sample data generated in the RavenStudio:

var indexQuery = new IndexQuery { Query = "Tag:categories" };
var operation = documentStore.Operations.Send(new DeleteByQueryOperation(indexQuery));
return operation;

However, it throws back the following exception:

Raven.Client.Exceptions.RavenException: Raven.Server.Documents.Queries.Parser.QueryParser+ParseException: 1:1 Expected FROM clause but got: Tag:categories

Query:
Tag:categories

Thanks in advance.

Andrej Krivulčík

unread,
Oct 17, 2017, 1:58:49 AM10/17/17
to RavenDB - 2nd generation document database
Use from categories in the query, instead of Tag:categories . RavenDB 4 uses RavenQL instead of Lucene syntax.

Fernando Ferreira Diniz de Moraes

unread,
Oct 17, 2017, 2:55:02 PM10/17/17
to RavenDB - 2nd generation document database
Good to know, works like a charm. Thanks!
Reply all
Reply to author
Forward
0 new messages