1
0
mirror of https://github.com/owncloud/ocis.git synced 2026-10-25 11:39:24 +03:00
Files
ocis/services/search/pkg/command/root.go
Paul Faure a17760898c feat(search): add ocis search optimize CLI command (#12136)
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

Signed-off-by: Paul Faure <paul@faure.ca>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Martin <github@diemattels.at>
2026-04-17 09:16:03 +00:00

37 lines
760 B
Go

package command
import (
"os"
"github.com/owncloud/ocis/v2/ocis-pkg/clihelper"
"github.com/owncloud/ocis/v2/services/search/pkg/config"
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
Index(cfg),
Optimize(cfg),
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-search command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultApp(&cli.App{
Name: "search",
Usage: "Serve search API for oCIS",
Commands: GetCommands(cfg),
})
return app.RunContext(cfg.Context, os.Args)
}