You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 5.1 version.
Operations: How to Put Indexes
PutIndexesOperation is used to insert indexes into a database.
Syntax
public PutIndexesOperation(params IndexDefinition[] indexToAdd)
Parameters | ||
---|---|---|
indexToAdd | params IndexDefinition[] |
Definitions of indexes |
Return Value | |
---|---|
PutIndexResult[] | List of created indexes |
Example I
IndexDefinition definition = new IndexDefinition
{
Maps = new HashSet<string> { @"from order in docs.Orders
select new
{
order.Employee,
order.Company,
Total = order.Lines.Sum(l => (l.Quantity * l.PricePerUnit) * (1 - l.Discount))
}" }
};
store.Maintenance.Send(new PutIndexesOperation(definition));
Example II
IndexDefinition definition = new IndexDefinitionBuilder<Order>
{
Map = orders => from order in orders
select new
{
order.Employee,
order.Company,
Total = order.Lines.Sum(l => (l.Quantity * l.PricePerUnit) * (1 - l.Discount))
}
}
.ToIndexDefinition(store.Conventions);
store.Maintenance.Send(new PutIndexesOperation(definition));