--------------------------------------------------------
(name string, indexDefsByName map[string]*cbgt.IndexDef, depth int)
| 170 | // -------------------------------------------------------- |
| 171 | |
| 172 | func sourceNamesForAlias(name string, indexDefsByName map[string]*cbgt.IndexDef, |
| 173 | depth int) ([]string, error) { |
| 174 | if depth > 50 { |
| 175 | return nil, errAliasExpansionTooDeep |
| 176 | } |
| 177 | |
| 178 | var rv []string |
| 179 | |
| 180 | indexDef, exists := indexDefsByName[name] |
| 181 | if exists && indexDef != nil && indexDef.Type == "fulltext-alias" { |
| 182 | aliasParams, err := parseAliasParams(indexDef.Params) |
| 183 | if err != nil { |
| 184 | return nil, fmt.Errorf("error expanding fulltext-alias: %v", err) |
| 185 | } |
| 186 | for aliasIndexName := range aliasParams.Targets { |
| 187 | aliasIndexDef, exists := indexDefsByName[aliasIndexName] |
| 188 | // if alias target doesn't exist, do nothing |
| 189 | if exists { |
| 190 | if aliasIndexDef.Type == "fulltext-alias" { |
| 191 | // handle nested aliases with recursive call |
| 192 | nestedSources, err := sourceNamesForAlias(aliasIndexName, |
| 193 | indexDefsByName, depth+1) |
| 194 | if err != nil { |
| 195 | return nil, err |
| 196 | } |
| 197 | rv = append(rv, nestedSources...) |
| 198 | } else { |
| 199 | sourceNames, err := getSourceNamesFromIndexDef(aliasIndexDef) |
| 200 | if err != nil { |
| 201 | return nil, err |
| 202 | } |
| 203 | rv = append(rv, sourceNames...) |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | return rv, nil |
| 210 | } |
| 211 | |
| 212 | func getSourceNamesFromIndexDef(indexDef *cbgt.IndexDef) ([]string, error) { |
| 213 | if len(indexDef.Params) > 0 { |