5

rI've looked at the questions and indeed the RavenDb docs. There's a little at RavenDb Index Replication Docs but there doesn't seem any guidance on how/when/where to create the IndexReplicationDestination

Our use case is very simple (it's a spike). We currently create new objects (Cows) and store them in Raven. We have a couple of queries created dynamically using LINQ (e.g. from c in session.Query<Cows> select c).

Now I can't see where I should define the index to replicate. Any ideas? I've got hold of the bundle and added it to the server directory (I'm assuming it should be in RavenDB.1.0.499\server\Plugins where RavenDB.1.0.499\server contains Raven.Server.exe)

Edit: Thanks Ayende... the answer below and in the ravendb groups helped. There was a facepalm moment. Regardless here's some detail that may help someone else. It really is very easy and indeed 'just works':

a) Ensure that the plugins are being picked up. You can view these in the statistics - available via the /localhost:8080/stats url (assuming default settings). You should see entries in 'Extensions' regarding to the IndexReplication bundle.

If not present ensure the versions of the DLLs (bundle and server) are the same

b) Ensure the index you want to replicate has been created. They can be created via Client API or HTTP API.

Client API:

public class Cows_List : AbstractIndexCreationTask<Cow>
{
    public Cows_List()
    {
        Map = cows => from c in cows select new { c.Status };
        Index( x => x.Status, FieldIndexing.Analyzed);
    }
}

HTTP API (in studio): //Cows/List docs.Cows .Select(q => new {Status = q.Status})

c) create the replication document. The clue here is DOCUMENT. Like everything stored, it too is a document. So after creating it must be stored in the Db :

var replicationDocument = new Raven.Bundles.IndexReplication.Data.IndexReplicationDestination { Id = "Raven/IndexReplication/Cows_List", ColumnsMapping = { {"Status", "Status"} }, ConnectionStringName = "Reports", PrimaryKeyColumnName = "Id", TableName = "cowSummaries" }; session.Store(replicationDocument); sesson.SaveChanges();

d) Ensure you have the following in the CLIENT (e.g. MVC app or Console)

e) Create the RDBMS schema. I have a table in 'cowReports' :

CREATE TABLE [dbo].[cowSummaries]( [Id] nvarchar NULL, [Status] nchar NULL)

My particular problem was not adding the index document to the store. I know. facepalm. Of course everything is a document. Works like a charm!

1 Answer 1

1

You need to define two things. a) An index that transform the document to the row shape. b) A document that tell RavenDB what is the connection string name, the table name, and the columns to map

4
  • Thanks Ayende - This is one of 2 things I'm finding tricky to establish with RavenDb (the rest has been very simple) 1) where/when do I create the ReplicationDocument, is it once per session ? or app ? I guess app... 2) session management with ASP.Net (I don't want to inject IDocumentStore - it's a wide interface to Stub or Mock) - I'd rather have a conversation (like nHiberante).
    – penderi
    Nov 4, 2011 at 9:03
  • Ok the Sessions are sorted (I'm using similar practises to nHibernate/Monorail - store session in HttpContext). But I'm afraid I'm still unclear on when / how to create the rteplication document and index... any guidance appreciated.
    – penderi
    Nov 4, 2011 at 9:20
  • Also.... I'm using dynamic indexes for querying. Where would I setup the dedicated indexes for the replication ?? I'm assuming the same place. Is this a once-per-webapp per scenario (i'm thinking app_start) ?
    – penderi
    Nov 4, 2011 at 9:58
  • Ok so the Replication/Destination 40-4 are standard -> I'm not replicating to another RavenDb instance. There's no output from IndexReplication - how can I find out what's going on...
    – penderi
    Nov 4, 2011 at 13:20

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.