MCPcopy
hub / github.com/zincsearch/zincsearch / GetAliasMap

Method GetAliasMap

pkg/core/aliaslist.go:122–156  ·  view source on GitHub ↗

GetAliasMap returns an ES compatible map of indexes to their aliases In the form: {"gitea_issues":{"aliases":{}},"gitea_codes.v1":{"aliases":{"gitea_codes":{}}}}

(targetIndexes, targetAliases []string)

Source from the content-addressed store, hash-verified

120//
121// {"gitea_issues":{"aliases":{}},"gitea_codes.v1":{"aliases":{"gitea_codes":{}}}}
122func (al *AliasList) GetAliasMap(targetIndexes, targetAliases []string) M {
123 al.lock.RLock()
124 top := M{}
125
126outerLoop:
127 for alias, indexes := range al.Aliases {
128 if len(targetAliases) > 0 && !zutils.SliceExists(targetAliases, alias) { // check if this is one of the aliased we're looking for
129 continue outerLoop
130 }
131
132 innerLoop:
133 for _, index := range indexes {
134 if len(targetIndexes) > 0 && !zutils.SliceExists(targetIndexes, index) { // check if this is one of the indexes we're looking for
135 continue innerLoop
136 }
137
138 indexMap, _ := top[index].(M)
139 if indexMap == nil {
140 indexMap = M{}
141 top[index] = indexMap
142 }
143
144 aliases, _ := indexMap["aliases"].(M)
145 if aliases == nil {
146 aliases = M{}
147 indexMap["aliases"] = aliases
148 }
149
150 aliases[alias] = struct{}{}
151 }
152 }
153
154 al.lock.RUnlock()
155 return top
156}

Callers 2

GetESAliasesFunction · 0.80

Calls 1

SliceExistsFunction · 0.92

Tested by 1