public PutIndex ( string name, Raven.Database.Indexing.IndexDefinition definition ) : string | ||
name | string | |
definition | Raven.Database.Indexing.IndexDefinition | |
return | string |
IDocumentStore store = new DocumentStore() { Url = "http://localhost:8080", DefaultDatabase = "mydb" }; store.Initialize(); using (var session = store.OpenSession()) { // create an index session.Advanced.DocumentStore.DatabaseCommands.PutIndex("MyIndex", new IndexDefinitionBuilder{ Map = docs => from doc in docs select new MyIndexResult { Id = doc.Id, Name = doc.Name } }); }
var indexDef = new IndexDefinition { Name = "MyIndex", Maps = { @"from doc in docs select new { doc.Name }" } }; using (var database = new DocumentDatabase()) { // update an existing index database.PutIndex(indexDef); }In this example, we create an index definition object that specifies the name of the index and the mapping function. We then use the PutIndex() method on an instance of DocumentDatabase class to update an existing index with the new definition. Overall, PutIndex() method provides an easy and flexible way to create or update indexes in RavenDB database using C#.
public PutIndex ( string name, Raven.Database.Indexing.IndexDefinition definition ) : string | ||
name | string | |
definition | Raven.Database.Indexing.IndexDefinition | |
return | string |