Add a flag to the reindex command to force a full reindex

That can be helpful when the search service configuration has changed,
e.g. by enabling TIKA. Previously files that had already been indexed
were not indexed again and thus were no part of the fulltext index.

Fixes #2285
Fixes #2578
This commit is contained in:
André Duffeck
2026-04-14 08:20:28 +02:00
parent 366296eba6
commit 60bcc6b0f2
10 changed files with 112 additions and 73 deletions
+8 -1
View File
@@ -29,6 +29,7 @@ func Index(cfg *config.Config) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
allSpacesFlag, _ := cmd.Flags().GetBool("all-spaces")
spaceFlag, _ := cmd.Flags().GetString("space")
forceReindexFlag, _ := cmd.Flags().GetBool("force-reindex")
if spaceFlag == "" && !allSpacesFlag {
return errors.New("either --space or --all-spaces is required")
}
@@ -48,7 +49,8 @@ func Index(cfg *config.Config) *cobra.Command {
c := searchsvc.NewSearchProviderService("eu.opencloud.api.search", grpcClient)
_, err = c.IndexSpace(context.Background(), &searchsvc.IndexSpaceRequest{
SpaceId: spaceFlag,
SpaceId: spaceFlag,
ForceReindex: forceReindexFlag,
}, func(opts *client.CallOptions) { opts.RequestTimeout = 10 * time.Minute })
if err != nil {
fmt.Println("failed to index space: " + err.Error())
@@ -68,6 +70,11 @@ func Index(cfg *config.Config) *cobra.Command {
false,
"index all spaces instead. This or --space is required.",
)
indexCmd.Flags().Bool(
"force-rescan",
false,
"force a rescan of all files, even if they are already indexed. This will make the indexing process much slower, but ensures that the index is up-to-date using the current search service configuration.",
)
return indexCmd
}