src/server/pkg/collection/collection.go
func (c *collection) indexDir(index *Index, indexVal interface{}) string {
	var indexValStr string
	if marshaller, ok := indexVal.(proto.Marshaler); ok {
		if indexValBytes, err := marshaller.Marshal(); err == nil {
			// use marshalled proto as index. This way we can rename fields without
			// breaking our index.
			indexValStr = string(indexValBytes)
		} else {
			// log error but keep going (this used to be the only codepath)
			log.Printf("ERROR trying to marshal index value: %v", err)
			indexValStr = fmt.Sprintf("%v", indexVal)
		}
	} else {
		indexValStr = fmt.Sprintf("%v", indexVal)
	}
	return path.Join(c.indexRoot(index), indexValStr)
}
func (c *collection) indexDir(index *Index, indexVal interface{}) string {
	var indexValStr string
	if marshaller, ok := indexVal.(proto.Marshaler); ok {
		if indexValBytes, err := marshaller.Marshal(); err == nil {
			// use marshalled proto as index. This way we can rename fields without
			// breaking our index.
			indexValStr = string(indexValBytes)
		} else {
			// log error but keep going (this used to be the only codepath)
			log.Printf("ERROR trying to marshal index value: %v", err)
			indexValStr = fmt.Sprintf("%v", indexVal)
		}
	} else {
		indexValStr = fmt.Sprintf("%v", indexVal)
	}
	return path.Join(c.indexRoot(index), indexValStr)
}
// See the documentation for `Index` for details.