Skip to content

feat(search): index arbitrary metadata for full-text search#2987

Open
flash7777 wants to merge 2 commits into
opencloud-eu:mainfrom
flash7777:fix/search-index-metadata
Open

feat(search): index arbitrary metadata for full-text search#2987
flash7777 wants to merge 2 commits into
opencloud-eu:mainfrom
flash7777:fix/search-index-metadata

Conversation

@flash7777

Copy link
Copy Markdown

Summary

Index all ArbitraryMetadata fields (stored as user.oc.md.* xattrs) in the search index and include metadata matches in search highlights.

Motivation

Applications that store domain-specific metadata via SetArbitraryMetadata (e.g. file references, document status, custom 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 + highlight metadata matches
bleve/backend.go Request highlights for Metadata.* fields
opensearch/convert Include metadata matches in OpenSearch highlights

Apology

Sorry about the previous PR #2977 — a tooling issue caused the entire build branch to be included instead of just the search changes. This is a clean replacement with only the relevant diff (6 files, 63 lines).

Test plan

  • Existing search (name, content, tags) works unchanged
  • Set custom metadata on a file via SetArbitraryMetadata
  • Search for the metadata value — returns the file
  • Metadata matches appear in search highlights (e.g. oy.fileReference: <mark>11.12.01</mark>)
  • Works with both Bleve and OpenSearch backends

flash added 2 commits June 21, 2026 13:33
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
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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 14 complexity · 0 duplication

Metric Results
Complexity 14
Duplication 0

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.

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.

1 participant