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
PutIndexesOperation(IndexDefinition... indexToAdd)
Parameters | ||
---|---|---|
indexToAdd | IndexDefinition... |
Definitions of indexes |
Return Value | |
---|---|
PutIndexResult[] | List of created indexes |
Example I
IndexDefinition indexDefinition = new IndexDefinition();
indexDefinition.setMaps(Collections.singleton("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(indexDefinition));
Example II
IndexDefinitionBuilder builder = new IndexDefinitionBuilder();
builder.setMap("from order in docs.Orders select new { " +
" order.Employee," +
" order.Company," +
" Total = order.Lines.Sum(l => (l.Quantity * l.PricePerUnit) * (1 - l.Discount))" +
"}");
IndexDefinition definition = builder.toIndexDefinition(store.getConventions());
store.maintenance()
.send(new PutIndexesOperation(definition));