in pkg/client/elasticsearch/query.go [234:259]
func getValue(path string, doc map[string]interface{}) (interface{}, error) {
segments := strings.Split(path, ".")
if !(len(segments) > 0) {
return 0, fmt.Errorf("no segment in path")
}
isLeaf := len(segments) == 1
root, segments := segments[0], segments[1:]
rootDoc, exists := doc[root]
if !exists {
keys := make([]string, 0, len(doc))
for k := range doc {
keys = append(keys, k)
}
return 0, fmt.Errorf("can't find leaf %s in [%s]", root, strings.Join(keys, ","))
}
if isLeaf {
// Value is expected
return rootDoc, nil
}
if innerDoc, ok := rootDoc.(map[string]interface{}); ok {
return getValue(strings.Join(segments, "."), innerDoc)
}
return 0, fmt.Errorf("not a document: %v", rootDoc)
}