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

Function parseIndexParams

pindex_bleve.go:775–832  ·  view source on GitHub ↗
(indexParams string)

Source from the content-addressed store, hash-verified

773}
774
775func parseIndexParams(indexParams string) (
776 bleveParams *BleveParams, kvConfig map[string]interface{},
777 bleveIndexType string, kvStoreName string, err error) {
778 var ip cbgt.IndexPrepParams
779 err = json.Unmarshal([]byte(indexParams), &ip)
780 if err != nil {
781 return nil, nil, "", "",
782 fmt.Errorf("bleve: new index, json marshal"+
783 " err: %v", err)
784 }
785
786 indexParams = ip.Params
787 bleveParams = NewBleveParams()
788 if len(indexParams) > 0 {
789 buf, err := bleveMappingUI.CleanseJSON([]byte(indexParams))
790 if err != nil {
791 return nil, nil, "", "",
792 fmt.Errorf("bleve: cleanse params, err: %v", err)
793 }
794
795 err = json.Unmarshal(buf, bleveParams)
796 if err != nil {
797 return nil, nil, "", "",
798 fmt.Errorf("bleve: parse params, err: %v", err)
799 }
800 }
801
802 if strings.HasPrefix(bleveParams.DocConfig.Mode, ConfigModeCollPrefix) {
803 if im, ok := bleveParams.Mapping.(*mapping.IndexMappingImpl); ok {
804 scope, err := validateScopeCollFromMappings(ip.SourceName,
805 im, false)
806 if err != nil {
807 return nil, nil, "", "", err
808 }
809 // if there are more than 1 collection then need to
810 // insert $scope#$collection field into the mappings
811 if multiCollection(scope.Collections) {
812 err = enhanceMappingsWithCollMetaField(im.TypeMapping)
813 if err != nil {
814 return nil, nil, "", "", err
815 }
816 ipBytes, err := json.Marshal(bleveParams)
817 if err != nil {
818 return nil, nil, "", "",
819 fmt.Errorf("bleve: new , json marshal,"+
820 " err: %v", err)
821 }
822 indexParams = string(ipBytes)
823 }
824
825 bleveParams.DocConfig.CollPrefixLookup =
826 initMetaFieldValCache(ip.IndexName, ip.SourceName, im)
827 }
828 }
829
830 kvConfig, bleveIndexType, kvStoreName = bleveRuntimeConfigMap(bleveParams)
831 return bleveParams, kvConfig, bleveIndexType, kvStoreName, nil
832}

Callers 2

NewBlevePIndexImplExFunction · 0.85
NewBlevePIndexImplFunction · 0.85

Calls 8

NewBleveParamsFunction · 0.85
multiCollectionFunction · 0.85
initMetaFieldValCacheFunction · 0.85
bleveRuntimeConfigMapFunction · 0.85
UnmarshalMethod · 0.80
MarshalMethod · 0.80

Tested by

no test coverage detected