1
0
mirror of https://github.com/owncloud/ocis.git synced 2026-10-23 23:29:02 +03:00
Files
ocis/services/search/pkg/content/basic.go
Paul Faure ee9b6f3007 refactor(search): replace Retrieve with Update, remove checksum guard
Address reviewer feedback:
- Remove checksum field from index (bloats index, not searched)
- Remove skipUnchangedContent guard (not needed with UpdateTags path)
- Replace engine.Retrieve() with engine.Update(id, mutateFn) that does
  get+mutate+set internally, avoiding public exposure of raw retrieval
- Simplify UpdateTags to use engine.Update() with mutation function

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 10:52:30 +01:00

43 lines
1008 B
Go

package content
import (
"context"
"time"
storageProvider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/reva/v2/pkg/tags"
"github.com/owncloud/reva/v2/pkg/utils"
)
// Basic is the simplest Extractor implementation.
type Basic struct {
logger log.Logger
}
// NewBasicExtractor creates a new Basic instance.
func NewBasicExtractor(logger log.Logger) (*Basic, error) {
return &Basic{logger: logger}, nil
}
// Extract literally just rearranges the inputs and processes them into a Document.
func (b Basic) Extract(_ context.Context, ri *storageProvider.ResourceInfo) (Document, error) {
doc := Document{
Name: ri.Name,
Size: ri.Size,
MimeType: ri.MimeType,
}
if m := ri.ArbitraryMetadata.GetMetadata(); m != nil {
if t, ok := m["tags"]; ok {
doc.Tags = tags.New(t).AsSlice()
}
}
if ri.Mtime != nil {
doc.Mtime = utils.TSToTime(ri.Mtime).UTC().Format(time.RFC3339Nano)
}
return doc, nil
}