Add Attr properties to Elasticsearch GetMapping API
@@ -26,11 +26,13 @@ package client
import (
"context"
+ "fmt"
"net/http"
"strings"
"time"
"github.com/olivere/elastic/v7"
+ "go.temporal.io/server/common/searchattribute"
"go.temporal.io/server/common/config"
"go.temporal.io/server/common/log"
@@ -299,6 +301,36 @@ func convertMappingBody(esMapping map[string]interface{}, indexName string) map[
}
for fieldName, fieldProp := range propMap {
+ if fieldName == searchattribute.Attr {
+ attrFieldMap, ok := fieldProp.(map[string]interface{})
+ if !ok {
+ continue
+ }
+ attrFieldProp, ok := attrFieldMap["properties"]
+ if !ok {
+ continue
+ }
+ attrBodyMap, ok := attrFieldProp.(map[string]interface{})
+ if !ok {
+ continue
+ }
+ for fieldName, fieldProp := range attrBodyMap {
+ fieldPropMap, ok := fieldProp.(map[string]interface{})
+ if !ok {
+ continue
+ }
+ tYpe, ok := fieldPropMap["type"]
+ if !ok {
+ continue
+ }
+ typeStr, ok := tYpe.(string)
+ if !ok {
+ continue
+ }
+ result[fmt.Sprintf("%s.%s", searchattribute.Attr, fieldName)] = typeStr
+ }
+ }
+
fieldPropMap, ok := fieldProp.(map[string]interface{})
if !ok {
continue
