Skip to content

Search: index arbitrary metadata for full-text search#2977

Draft
flash7777 wants to merge 10 commits into
opencloud-eu:mainfrom
flash7777:feature/search-index-metadata
Draft

Search: index arbitrary metadata for full-text search#2977
flash7777 wants to merge 10 commits into
opencloud-eu:mainfrom
flash7777:feature/search-index-metadata

Conversation

@flash7777

Copy link
Copy Markdown

Summary

  • Index all ArbitraryMetadata fields (stored as user.oc.md.* xattrs) in the search index, not just tags
  • Custom metadata like oy.fileReference, oy.status, oy.subject, and user-defined fields become discoverable through the standard OpenCloud search
  • Metadata is stored as a dynamic Bleve sub-document with lowercase keyword analysis

Motivation

Applications that store domain-specific metadata via SetArbitraryMetadata (e.g. DMS file references, document status, custom index fields) currently cannot leverage the built-in search. Users expect to find documents by their metadata values, not just by filename or content.

Changes

File Change
content/content.go Add Metadata map[string]string to Document
content/basic.go Extract all ArbitraryMetadata entries (not just tags)
bleve/index.go Add dynamic Metadata sub-document mapping
bleve/bleve.go Reconstruct Metadata map from search results

Test plan

  • Verify existing search (name, content, tags) still works unchanged
  • Set custom metadata on a file via SetArbitraryMetadata
  • Search for the metadata value — should return the file
  • Verify metadata fields appear in search results

flash and others added 9 commits June 14, 2026 18:57
Add four new LibreGraph driveItem actions for the container-specific
and immutable permissions introduced in cs3org/cs3apis#272:

- DriveItemContainerDelete  → CS3 DeleteContainer (delete folders)
- DriveItemContainerUpdate  → CS3 MoveContainer (move/rename folders)
- DriveItemImmutableFileSet → CS3 SetImmutableFile (freeze files)
- DriveItemImmutableFolderSet → CS3 SetImmutableContainer (protect folders)

Conversion functions updated in both directions (CS3 ↔ LibreGraph).
Role definitions automatically pick up the new actions via
CS3ResourcePermissionsToLibregraphActions().

Depends on: opencloud-eu/reva#676 (go-cs3apis bump with new fields)
…ources

Three new Graph API endpoints on drive items:

  POST   /drives/{driveID}/items/{itemID}/freeze    - freeze a file (irreversible)
  POST   /drives/{driveID}/items/{itemID}/protect   - protect a directory (reversible)
  DELETE /drives/{driveID}/items/{itemID}/protect    - unprotect a directory

Semantics:
- freeze: sets immutable on files, cannot be undone, client must confirm
- protect: sets immutable on directories, can be reversed by managers
- unprotect: removes immutable from directories

Each endpoint validates the resource type (file vs directory) and returns
appropriate errors for type mismatches, permission denied, and not found.

Depends on: opencloud-eu/reva#676 (SetImmutable/UnsetImmutable RPCs)
1. GET /drives/{driveID}/items/{itemID}/metadata
   Returns all custom metadata (user.oc.md.*) as JSON.
   Tested: oy.* Aktenplan metadata successfully returned.

2. Container/immutable permission actions (conversion.go, roles.go)
   DriveItemContainerDelete, DriveItemContainerUpdate,
   DriveItemImmutableFileSet, DriveItemImmutableFolderSet

3. Labels API fix (follow.go)
   provider.AddLabelRequest → labels.AddLabelRequest
- freeze/protect/unprotect Graph API endpoints
- go-cs3apis replace in Dockerfile for gateway SetImmutable
- .dockerignore for clean builds
Register "kosmos" as a valid edition so the version output shows
"Edition: kosmos" instead of falling back to "dev" with an error log.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New global role "Manager" (User + Drives.ManageImmutable) allows
protect/unprotect/freeze on any space without needing the space-level
Manager role. Also adds ManageImmutable to Admin and SpaceAdmin roles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allows setting arbitrary metadata (user.oc.md.*) on drive items via
PUT /graph/v1beta1/drives/{driveID}/items/{itemID}/metadata with a
JSON body of key-value pairs. Complements the existing GET endpoint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All ArbitraryMetadata fields (stored as user.oc.md.* xattrs) are now
extracted during content indexing and stored in a searchable Metadata
sub-document in the Bleve index.

Previously only the "tags" field was extracted from ArbitraryMetadata.
Now all fields are indexed, making custom metadata like oy.fileReference
(Aktenzeichen), oy.status, oy.subject, and user-defined info.* fields
discoverable through the standard OpenCloud search.

Changes:
- content.go: add Metadata map[string]string to Document
- basic.go: extract all ArbitraryMetadata entries (not just tags)
- bleve/index.go: add dynamic Metadata sub-document mapping
- bleve/bleve.go: reconstruct Metadata map from search results
@codacy-production

codacy-production Bot commented Jun 18, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 medium · 97 minor

Alerts:
⚠ 100 issues (≤ 0 issues of at least minor severity)

Results:
100 new issues

Category Results
BestPractice 3 medium
CodeStyle 97 minor

View in Codacy

🟢 Metrics 50 complexity · -118 duplication

Metric Results
Complexity 50
Duplication -118

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

When a search matches on metadata fields (e.g. oy.fileReference,
oy.subject), the highlight now includes the matched field name and
value, separated by " · " from content highlights.

Example highlight: "oy.fileReference: <mark>11.12.01</mark>"

Applied to both Bleve and OpenSearch backends.
@dragonchaser dragonchaser marked this pull request as draft June 19, 2026 07:46
@dragonchaser

dragonchaser commented Jun 19, 2026

Copy link
Copy Markdown
Member

This PR is in no reviewable condition, please clean it up first. Converting it to draft (for now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants