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

Method BuildDocumentEx

pindex_bleve_doc.go:142–178  ·  view source on GitHub ↗
(key, val []byte,
	defaultType string, extrasType cbgt.DestExtrasType,
	extras []byte)

Source from the content-addressed store, hash-verified

140}
141
142func (b *BleveDocumentConfig) BuildDocumentEx(key, val []byte,
143 defaultType string, extrasType cbgt.DestExtrasType,
144 extras []byte) (*BleveDocument, []byte, error) {
145 var cmf *collMetaField
146 if len(extras) >= 8 {
147 cmf = b.CollPrefixLookup[binary.LittleEndian.Uint32(extras[4:])]
148 }
149
150 var v map[string]interface{}
151 err := json.Unmarshal(val, &v)
152 if err != nil || v == nil {
153 v = map[string]interface{}{}
154 }
155
156 if cmf != nil && len(b.CollPrefixLookup) > 1 {
157 // more than 1 collection indexed
158 key = append(extras[4:8], key...)
159 v[CollMetaFieldName] = cmf.value
160 }
161
162 bdoc := b.BuildDocumentFromObj(key, v, defaultType)
163 if !b.legacyMode && cmf != nil {
164 typ := cmf.scopeDotColl
165 // there could be multiple type mappings under a single collection.
166 for _, t := range cmf.typeMappings {
167 if len(t) > 0 && bdoc.Type() == t {
168 // append type information only if the type mapping specifies a
169 // 'type' and the document's matches it.
170 typ += "." + t
171 break
172 }
173 }
174 bdoc.SetType(typ)
175 }
176
177 return bdoc, key, err
178}
179
180// BuildDocument returns a BleveDocument for the k/v pair
181// NOTE: err may be non-nil AND a document is returned

Callers 1

DataUpdateMethod · 0.80

Calls 4

BuildDocumentFromObjMethod · 0.95
UnmarshalMethod · 0.80
TypeMethod · 0.80
SetTypeMethod · 0.80

Tested by

no test coverage detected