PutIndexes creates multiple indexes with specified names, using given index definitions and priorities.
Syntax
curl \
http://{serverName}/databases/{databaseName}/indexes \
-X PUT \
-d @indexesToAdd.txt
Response
Status code |
Description |
201 |
Created |
Return Value |
Description |
Indexes[] |
Array of names of created indexes |
Example
curl -X PUT "http://localhost:8080/databases/NorthWind/indexes" \
-d "[{'Name':'Orders/Totals', \
'Definition':{ \
'MaxIndexOutputsPerDocument':null, \
'IndexId':0, \
'Name':null, \
'LockMode':'Unlock', \
'Maps':['from order in docs.Orders select new { order.Employee, order.Company, Total = order.Lines.Sum(l => (l.Quantity * l.PricePerUnit) * (1 - l.Discount))}'], \
'Reduce':null, \
'Stores':{}, \
'Indexes':{}, \
'SortOptions':{}, \
'Analyzers':{}, \
'Fields':[], \
'Suggestions':{}, \
'TermVectors':{}, \
'SpatialIndexes':{}, \
'DisableInMemoryIndexing':false, \
'Type':'Map', \
'Map':' from order in docs.Orders select new { order.Employee, order.Company, Total = order.Lines.Sum(l => (l.Quantity * l.PricePerUnit) * (1 - l.Discount))}', \
'IsCompiled':false, \
'IsMapReduce':false \
}, \
'Priority':'Normal'}, \
{'Name':'Product/Sales', \
'Definition':{ \
'MaxIndexOutputsPerDocument':null, \
'IndexId':0, \
'Name':null, \
'LockMode':'Unlock', \
'Maps':['from order in docs.Orders from line in order.Lines select new { Product = line.Product, Count = 1, Total = ((line.Quantity * line.PricePerUnit) * ( 1 - line.Discount)) }'], \
'Reduce':null, \
'Stores':{}, \
'Indexes':{}, \
'SortOptions':{}, \
'Analyzers':{}, \
'Fields':[], \
'Suggestions':{}, \
'TermVectors':{}, \
'SpatialIndexes':{}, \
'DisableInMemoryIndexing':false, \
'Type':'MapReduce', \
'Map':'from order in docs.Orders from line in order.Lines select new { Product = line.Product, Count = 1, Total = ((line.Quantity * line.PricePerUnit) * ( 1 - line.Discount)) }', \
'IsCompiled':false, \
'IsMapReduce':false \
}, \
'Priority':'Normal'}]"
< HTTP/1.1 201 Created
{"Indexes":["Orders/Totals", "Product/Sales"]}