## Step 3: Drop the index. 

To modify the index, you must drop the index first. 

db.orders.dropIndex( { "cust_id" : 1, "ord_date" : -1, "items" : 1 } ) 

The method returns a document with the status of the operation. Upon successful operation, the ok field in the returned document should specify a 1 . See Remove Indexes (page 524) for more information about dropping indexes. 

## Step 4: Recreate the index without the unique constraint. 

Recreate the index without the unique constraint. 

db.orders.createIndex( { "cust_id" : 1, "ord_date" : -1, "items" : 1 } ) 

The method returns a document with the status of the results. Upon successful operation, the returned document should show the numIndexesAfter to be greater than numIndexesBefore by one. 

## See also: 

Index Introduction (page 481), Index Concepts (page 486). 

## Rebuild Indexes 

If you need to rebuild indexes for a collection you can use the db.collection.reIndex() method to rebuild all indexes on a collection in a single operation. This operation drops all indexes, including the _id index (page 487), and then rebuilds all indexes. 

## See also: 

Index Concepts (page 486) and Indexing Tutorials (page 517). 

## Process 

The operation takes the following form: 

db.accounts.reIndex() 

MongoDB will return the following document when the operation completes: 

{ "nIndexesWas" : 2, "msg" : "indexes dropped for collection", "nIndexes" : 2, "indexes" : [ { "key" : { "_id" : 1, "tax-id" : 1 }, "ns" : "records.accounts", "name" : "_id_" } 

