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

Function processAliasResponse

pindex_alias.go:145–178  ·  view source on GitHub ↗
(searchResponse *bleve.SearchResult)

Source from the content-addressed store, hash-verified

143}
144
145func processAliasResponse(searchResponse *bleve.SearchResult) {
146 if searchResponse != nil {
147 if len(searchResponse.Hits) > 0 {
148 for _, hit := range searchResponse.Hits {
149 // extract indexName for the hit's Index field, which holds the pindex name;
150 // a pindex name has the format ..
151 // default_2d9ca20632cb632e_4c1c5584
152 // where "default" is the index name
153 var indexName string
154 if x := strings.LastIndex(hit.Index, "_"); x > 0 && x < len(hit.Index) {
155 temp := hit.Index[:x]
156 if x = strings.LastIndex(temp, "_"); x > 0 && x < len(hit.Index) {
157 indexName = temp[:x]
158 }
159 }
160
161 // if this is a multi collection index, then strip the collection UID
162 // from the hit ID and fill the details of source collection
163 if sdm, multiCollIndex :=
164 metaFieldValCache.getSourceDetailsMap(indexName); multiCollIndex {
165 idBytes := []byte(hit.ID)
166 cuid := binary.LittleEndian.Uint32(idBytes[:4])
167 if collName, ok := sdm.collUIDNameMap[cuid]; ok {
168 hit.ID = string(idBytes[4:])
169 if hit.Fields == nil {
170 hit.Fields = make(map[string]interface{})
171 }
172 hit.Fields["_$c"] = collName
173 }
174 }
175 }
176 }
177 }
178}
179
180func parseAliasParams(aliasDefParams string) (*AliasParams, error) {
181 params := AliasParams{}

Callers 1

QueryAliasFunction · 0.85

Calls 1

getSourceDetailsMapMethod · 0.80

Tested by

no test coverage detected