(key, val []byte, defaultType string, extrasType cbgt.DestExtrasType, extras []byte)
| 140 | } |
| 141 | |
| 142 | func (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 |
no test coverage detected