code: func (idx *index) rebuild() {
  	// initialize trees
  	if idx.less != nil {
  		idx.btr = btree.New(btreeDegrees, idx)
  	}
  	if idx.rect != nil {
  		idx.rtr = rtree.New(idx)
  	}
  	// iterate through all keys and fill the index
  	idx.db.keys.Ascend(func(item btree.Item) bool {
  		dbi := item.(*dbItem)
  		if !idx.match(dbi.key) {
  			// does not match the pattern, conintue
  			return true
  		}
  		if idx.less != nil {
  			idx.btr.ReplaceOrInsert(dbi)
  		}
  		if idx.rect != nil {
  			idx.rtr.Insert(dbi)
  		}
  		return true
  	})
  }
docs: // rebuild rebuilds the index