Skip to content

Commit

Permalink
Fixed opening an existing index
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony V. Ozdemir committed May 31, 2023
1 parent 35550c9 commit 254412f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/task_handlers/indexers/basic_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ type BasicIndexer struct {
}

func (b *BasicIndexer) Initialize(config config.TaskHandlerOptions, baseFolder string, outputLimit int64) error {
// Configure default indexing mapping
indexMapping := bleve.NewIndexMapping()
index, err := bleve.New(baseFolder, indexMapping)

// Try to open an existing index
index, err := bleve.Open(baseFolder)

// If the index doesn't exist, create a new one
if err != nil {
return err
indexMapping := bleve.NewIndexMapping()
index, err = bleve.New(baseFolder, indexMapping)
if err != nil {
return err
}
}

b.index = index
Expand Down

0 comments on commit 254412f

Please sign in to comment.