Skip to content

feat(search): add a --force flag to the search index command - #13449

Open
officialasishkumar wants to merge 2 commits into
owncloud:masterfrom
officialasishkumar:feat/search-index-force
Open

officialasishkumar wants to merge 2 commits into
owncloud:masterfrom
officialasishkumar:feat/search-index-force

Conversation

@officialasishkumar

Copy link
Copy Markdown

Description

Adds a --force flag to ocis search index. Without it nothing changes: files that are already indexed and unchanged are skipped. With it, every file of the given space (or of all spaces with --all-spaces) is extracted and indexed again.

Changes:

  • IndexSpaceRequest gets a force field (generated protobuf, swagger and the Searcher mock are regenerated with the pinned tool versions).
  • Searcher.IndexSpace takes a force parameter; the "already indexed and unchanged" check is bypassed when it is set. The event handlers pass false.
  • --force flag on the command, README section and changelog entry.

Related Issue

Motivation and Context

After a change that affects the extracted data, e.g. enabling OCR in Tika, already indexed files are never revisited. The only way to rebuild their entries was deleting the bleve database, which leaves search unavailable until it is rebuilt. With --force the entries are replaced in place and stay searchable.

How Has This Been Tested?

  • test environment: linux/arm64, Go 1.26
  • go test ./services/search/... passes
  • new test: an indexed, unchanged file is skipped by default and extracted and upserted again with force; verified that the forced test fails when the !force condition is removed
  • the event handler test now asserts IndexSpace is called with force=false
  • regenerated code produces only the expected diff for the force field

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

`ocis search index` skips every file that is already indexed and has not
changed since the last extraction. After a change that affects the
extracted data, such as enabling OCR in Tika, there was no way to index
those files again short of deleting the whole bleve index, which makes
search unavailable until it has been rebuilt.

Add a `force` field to IndexSpaceRequest and a `--force` flag to the
command. When set, IndexSpace no longer short-circuits on the stored
mtime and extracts and upserts every resource of the requested space or
of all spaces. Existing index entries are replaced in place, so search
keeps working during the run. The event handlers keep passing false, so
their behaviour is unchanged.

The Searcher interface gains the force parameter; the generated protobuf
code, swagger file and mockery mock are regenerated with the pinned
tool versions. Tests cover that an unchanged file is skipped by default
and indexed again when forced, and that events never force.

Fixes owncloud#9106

Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
@officialasishkumar
officialasishkumar requested a review from a team as a code owner November 12, 2026 13:27
@kw-security

kw-security commented Nov 12, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@LarsJurgensen LarsJurgensen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thank you! 👍

This branch has not been deployed

No deployments
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.

search: force re-index command

3 participants