code: func (db *DB) ReplaceIndex(name, pattern string,
  	less ...func(a, b string) bool) error {
  	return db.Update(func(tx *Tx) error {
  		err := tx.CreateIndex(name, pattern, less...)
  		if err != nil {
  			if err == ErrIndexExists {
  				err := tx.DropIndex(name)
  				if err != nil {
  					return err
  				}
  				return tx.CreateIndex(name, pattern, less...)
  			}
  			return err
  		}
  		return nil
  	})
  }
docs: // ReplaceIndex builds a new index and populates it with items.
  // The items are ordered in an b-tree and can be retrieved using the
  // Ascend* and Descend* methods.
  // If a previous index with the same name exists, that index will be deleted.
  //
  // Deprecated: Use Transactions