Search code examples
ravendbsharding

Index Creation Failing for ShardedDocumentStore and Sharded Linq Queries Not Supported


I just implemented sharding with RavenDB. When running it for the first time, this code:

tempShardedDocumentStore = new ShardedDocumentStore(new ShardStrategy(), shards);
tempShardedDocumentStore.Initialize();

IndexCreation.CreateIndexes(typeof(RavenDataAccess).Assembly, tempShardedDocumentStore);

... produces this error:

System.TypeInitializationException: The type initializer for 'WriteToRaven.Data. RavenDataAccess' threw an exception. ---> System.NotSupportedException: Sharded document store doesn't have a database commands. you need to explicitly use the shard instances to get access to the database commands

First, ShardedDocumentStore does indeed have DatabaseCommands:

enter image description here

Second, if that just won't work, should it be done like this?

IndexCreation.CreateIndexes(typeof(RavenDataAccess).Assembly, shards[0]);

If so, now my linq query won't work:

System.NotSupportedException: Sharded linq queries aren't supported currently at Raven.Client.Shard.ShardedDocumentSession.QueryT

using (IDocumentSession ravenSession = GetRavenSession())
{
    return ravenSession.Query<T>().OrderByDescending(orderByClause).FirstOrDefault();
}

How do I get this to work?

Note: GetRavenSession() returns OpenSession() from the sharded document store shown above.


Solution

  • Bob Horn, What build are you using? We recently revamped the sharding support. We have support for linq in sharding now, as well as creating indexes.