feat(search): add ocis search optimize CLI command#12136
feat(search): add ocis search optimize CLI command#12136mmattel merged 2 commits intoowncloud:masterfrom
ocis search optimize CLI command#12136Conversation
|
577b800 to
8658473
Compare
8658473 to
a6c10a2
Compare
a6c10a2 to
b0abcb9
Compare
b0abcb9 to
55d1348
Compare
55d1348 to
8374d95
Compare
|
I'm more inclined to keep it as "cli-only". Exposing this as part of the GRPC interface doesn't seem a good idea: users of the service shouldn't care about optimizing the service itself nor care about its internals. In addition, the optimization might take a while (likely minutes if not hours), and during that time the search service will be locked and unusable (at least with bleve). Instead, you can create an engine factory (moving the related code from the GRPC service, https://github.com/owncloud/ocis/blob/master/services/search/pkg/service/grpc/v0/service.go#L45-L69) and use it inside your command to have access to the search engine. You can run the "optimize" function from there.
That seems an ideal scenario that won't happen. We need to consider the worst possible scenario, and I don't think we can ensure that it will ALWAYS take less than a second to complete the execution. In this case, we should consider it a long running operation, and also a blocking operation. This is why a prefer to ensure that the optimization is run through command line only, so the admin triggers it at the best time minimizing the disruption. Side note, I've seen you've added an optional |
0f2f458 to
e5b1895
Compare
|
Thanks for the detailed feedback @jvillafanez — all three points addressed:
Good call on the blocking concern — with direct index access, the admin controls when it runs and there's no risk of locking the running service. |
|
In general, the code looks better now 👍 |
Add a CLI-only optimize command that compacts the Bleve search index by merging segments. The command opens the index directly via a new engine factory (NewEngineFromConfig), without requiring the running gRPC service. Key changes per review feedback from jvillafanez: - CLI-only: no gRPC endpoint, no proto changes — admin triggers it directly when disruption is acceptable - Engine factory: extracted engine creation from the gRPC handler into NewEngineFromConfig, reusable by both the service and CLI commands - Optimize() merged into Engine interface: no separate Optimizer interface, non-supporting engines can return an error Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Faure <paul@faure.ca>
e5b1895 to
3d6009f
Compare



Summary
ocis search optimizeCLI command that compacts the Bleve search index by merging segments (ForceMerge), improving query performance without re-indexing contentgoogle.protobuf.Emptyfor theOptimizeIndexRPC to avoid creating new message typesBackground
After bulk re-indexing (e.g.
ocis search index), the Bleve index can accumulate many small segments that degrade query performance. Currently the only way to compact them is programmatically via theForceMergeAPI added in #12104. This PR exposes that capability as a simple CLI command so administrators can trigger optimization on demand.Requested by @mklos-kw in the context of #12104.
Changes
search.protoOptimizeIndexRPC (Empty → Empty)search.pb.micro.gosearch.pb.web.goservice.go(search)OptimizeIndextoSearcherinterface + implementationservice.go(grpc)Searcher.OptimizeIndexoptimize.goroot.goOptimizein command listmocks/changelog/Usage
ocis search optimize # Output: index optimization completeTest plan
make -C services/search test— all 35 tests pass🤖 Generated with Claude Code