Merge fceee6be89
into 1f7faf7e01
This commit is contained in:
commit
da968949e4
13
index.go
13
index.go
|
@ -246,7 +246,7 @@ func NewUsing(path string, mapping mapping.IndexMapping, indexType string, kvsto
|
|||
// Open index at the specified path, must exist.
|
||||
// The mapping used when it was created will be used for all Index/Search operations.
|
||||
func Open(path string) (Index, error) {
|
||||
return openIndexUsing(path, nil)
|
||||
return openIndexUsing(path, nil, nil)
|
||||
}
|
||||
|
||||
// OpenUsing opens index at the specified path, must exist.
|
||||
|
@ -254,5 +254,14 @@ func Open(path string) (Index, error) {
|
|||
// The provided runtimeConfig can override settings
|
||||
// persisted when the kvstore was created.
|
||||
func OpenUsing(path string, runtimeConfig map[string]interface{}) (Index, error) {
|
||||
return openIndexUsing(path, runtimeConfig)
|
||||
return openIndexUsing(path, nil, runtimeConfig)
|
||||
}
|
||||
|
||||
// OpenUsingMapping opens index at the specified path, must exist.
|
||||
// The mapping used when it was created will be used for all Index/Search operations.
|
||||
// The provided runtimeConfig can override settings
|
||||
// persisted when the kvstore was created.
|
||||
// The provided mapping will be used for all, when alias use multiple the same index mapping.
|
||||
func OpenUsingMapping(path string, mapping mapping.IndexMapping) (Index, error) {
|
||||
return openIndexUsing(path, mapping, nil)
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ func newIndexUsing(path string, mapping mapping.IndexMapping, indexType string,
|
|||
return &rv, nil
|
||||
}
|
||||
|
||||
func openIndexUsing(path string, runtimeConfig map[string]interface{}) (rv *indexImpl, err error) {
|
||||
func openIndexUsing(path string, indexMapping mapping.IndexMapping, runtimeConfig map[string]interface{}) (rv *indexImpl, err error) {
|
||||
rv = &indexImpl{
|
||||
path: path,
|
||||
name: path,
|
||||
|
@ -178,6 +178,23 @@ func openIndexUsing(path string, runtimeConfig map[string]interface{}) (rv *inde
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// use mapping
|
||||
if indexMapping != nil {
|
||||
err = indexMapping.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// mark the index as open
|
||||
rv.mutex.Lock()
|
||||
defer rv.mutex.Unlock()
|
||||
rv.open = true
|
||||
|
||||
rv.m = indexMapping
|
||||
indexStats.Register(rv)
|
||||
return rv, err
|
||||
}
|
||||
|
||||
// now load the mapping
|
||||
indexReader, err := rv.i.Reader()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue