1

How to add a index to specific database in RavenDb 4. I see the function

new SearchableIndex().Execute(_documentStore);

How to specify the database, without setting the default database as part of document store initialization. I wish to pass the database name as parameter.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Abhay Naik
  • 410
  • 3
  • 15
  • One way is to set .Database property _documentStore. Not sure if thats the best way to do it. But it works. – Abhay Naik Nov 29 '17 at 22:00
  • You have to document store. You could accept a database name parameter in your own function, then create a document store with that database and execute the index against that document store. – Judah Gabriel Himango Nov 30 '17 at 16:38

1 Answers1

1

You set the database for the DocumentStore using the Database property. When initializing, do it like this:

var _documentStore = new DocumentStore
{
    Urls = new[] { "http://localhost:8080" },
    Database = "databaseName"
};

new SearchableIndex().Execute(_documentStore);