MCPcopy Create free account
hub / github.com/couchbase/cbft / OpenBlevePIndexImplUsing

Function OpenBlevePIndexImplUsing

pindex_bleve.go:1005–1077  ·  view source on GitHub ↗
(indexType, path, indexParams string,
	restart func())

Source from the content-addressed store, hash-verified

1003}
1004
1005func OpenBlevePIndexImplUsing(indexType, path, indexParams string,
1006 restart func()) (cbgt.PIndexImpl, cbgt.Dest, error) {
1007 buf := []byte(indexParams)
1008 var err error
1009 if len(buf) == 0 {
1010 buf, err = ioutil.ReadFile(path +
1011 string(os.PathSeparator) + "PINDEX_BLEVE_META")
1012 if err != nil {
1013 return nil, nil, err
1014 }
1015 }
1016
1017 bleveParams := NewBleveParams()
1018 if len(buf) > 0 {
1019 // It is possible that buf is empty when index params aren't set as
1020 // part of the index definition.
1021 buf, err = bleveMappingUI.CleanseJSON(buf)
1022 if err != nil {
1023 return nil, nil, fmt.Errorf("bleve: cleanse params, err: %v", err)
1024 }
1025
1026 err = json.Unmarshal(buf, bleveParams)
1027 if err != nil {
1028 return nil, nil, fmt.Errorf("bleve: parse params: %v", err)
1029 }
1030 }
1031
1032 if strings.HasPrefix(bleveParams.DocConfig.Mode, ConfigModeCollPrefix) {
1033 if am, ok := bleveParams.Mapping.(*mapping.IndexMappingImpl); ok {
1034 buf, err = ioutil.ReadFile(path +
1035 string(os.PathSeparator) + "PINDEX_META")
1036 if err != nil {
1037 return nil, nil, err
1038 }
1039 tmp := struct {
1040 SourceName string `json:"sourceName"`
1041 IndexName string `json:"indexName"`
1042 }{}
1043
1044 err = json.Unmarshal(buf, &tmp)
1045 if err != nil {
1046 return nil, nil, fmt.Errorf("bleve: parse params: %v", err)
1047 }
1048 // populate the collection meta field look up cache.
1049 bleveParams.DocConfig.CollPrefixLookup =
1050 initMetaFieldValCache(tmp.IndexName, tmp.SourceName, am)
1051 }
1052 }
1053
1054 // Handle the case where indexType wasn't mentioned in
1055 // the index params (only from pre 5.5 nodes)
1056 if !strings.Contains(indexParams, "indexType") {
1057 bleveParams.Store["indexType"] = upsidedown.Name
1058 if !strings.Contains(indexParams, "kvStoreName") {
1059 bleveParams.Store["kvStoreName"] = "mossStore"
1060 }
1061 }
1062

Callers 1

OpenBlevePIndexImplFunction · 0.85

Calls 6

NewBleveParamsFunction · 0.85
initMetaFieldValCacheFunction · 0.85
bleveRuntimeConfigMapFunction · 0.85
NewBleveDestFunction · 0.85
UnmarshalMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected