diff --git a/cmd/indexer/main.go b/cmd/indexer/main.go index 4110bfe..c569844 100644 --- a/cmd/indexer/main.go +++ b/cmd/indexer/main.go @@ -307,11 +307,17 @@ func indexVerses(sugar *zap.SugaredLogger, tsClient *typesense.Client, mongoDB * TokenSeparators: &hyphenSeparators, } - _, err := tsClient.Collections().Create(context.Background(), schema) - if err != nil { - sugar.Fatalf("[verses] Failed to create collection: %v", err) + // Create the collection; tolerate "already exists" so a --no-drop run can + // upsert into the live collection without dropping it (matches indexProse). + if _, err := tsClient.Collections().Create(context.Background(), schema); err != nil { + if strings.Contains(err.Error(), "already exists") { + sugar.Warnf("[verses] Create collection: %v (continuing — upserting into existing)", err) + } else { + sugar.Fatalf("[verses] Failed to create collection: %v", err) + } + } else { + sugar.Info("[verses] Collection created") } - sugar.Info("[verses] Collection created") // Read from MongoDB ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)