@@ -49,7 +49,7 @@ func NewIndexGetterMemory(mapping mapping.IndexMapping) *IndexGetterMemory {
49
49
50
50
// GetIndex creates a new in-memory index every time it is called.
51
51
// The options are ignored in this implementation.
52
- func (i * IndexGetterMemory ) GetIndex (opts ... GetIndexOption ) (bleve.Index , func (), error ) {
52
+ func (i * IndexGetterMemory ) GetIndex (_ ... GetIndexOption ) (bleve.Index , func (), error ) {
53
53
closeFn := func () {} // no-op
54
54
if i .index != nil {
55
55
return i .index , closeFn , nil
@@ -90,7 +90,7 @@ func NewIndexGetterPersistent(rootDir string, mapping mapping.IndexMapping) *Ind
90
90
91
91
// GetIndex returns the cached index. The options are ignored in this
92
92
// implementation.
93
- func (i * IndexGetterPersistent ) GetIndex (opts ... GetIndexOption ) (bleve.Index , func (), error ) {
93
+ func (i * IndexGetterPersistent ) GetIndex (_ ... GetIndexOption ) (bleve.Index , func (), error ) {
94
94
closeFn := func () {} // no-op
95
95
if i .index != nil {
96
96
return i .index , closeFn , nil
@@ -103,6 +103,8 @@ func (i *IndexGetterPersistent) GetIndex(opts ...GetIndexOption) (bleve.Index, f
103
103
if err != nil {
104
104
return nil , closeFn , err
105
105
}
106
+ } else if err != nil {
107
+ return nil , closeFn , err
106
108
}
107
109
108
110
i .index = index
@@ -142,16 +144,17 @@ func (i *IndexGetterPersistentScale) GetIndex(opts ...GetIndexOption) (bleve.Ind
142
144
params := map [string ]interface {}{
143
145
"read_only" : options .ReadOnly ,
144
146
}
147
+
148
+ closeFn := func () {} // no-op
145
149
index , err := bleve .OpenUsing (destination , params )
146
150
if errors .Is (bleve .ErrorIndexPathDoesNotExist , err ) {
147
151
index , err = bleve .New (destination , i .mapping )
148
152
if err != nil {
149
- closeFn := func () {} // no-op
150
153
return nil , closeFn , err
151
154
}
152
-
153
- return index , func () { index . Close () }, nil
155
+ } else if err != nil {
156
+ return nil , closeFn , err
154
157
}
155
158
156
- return index , func () { index .Close () }, err
159
+ return index , func () { index .Close () }, nil
157
160
}
0 commit comments