Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update type of keyword list search attributes #3865

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func buildMappingBody(mapping map[string]enumspb.IndexedValueType) map[string]in
switch fieldType {
case enumspb.INDEXED_VALUE_TYPE_TEXT:
typeMap = map[string]interface{}{"type": "text"}
case enumspb.INDEXED_VALUE_TYPE_KEYWORD:
case enumspb.INDEXED_VALUE_TYPE_KEYWORD, enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST:
typeMap = map[string]interface{}{"type": "keyword"}
case enumspb.INDEXED_VALUE_TYPE_INT:
typeMap = map[string]interface{}{"type": "long"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,10 @@ func finishParseJSONValue(val interface{}, t enumspb.IndexedValueType) (interfac
}

switch t {
case enumspb.INDEXED_VALUE_TYPE_TEXT, enumspb.INDEXED_VALUE_TYPE_KEYWORD, enumspb.INDEXED_VALUE_TYPE_DATETIME:
case enumspb.INDEXED_VALUE_TYPE_TEXT,
enumspb.INDEXED_VALUE_TYPE_KEYWORD,
enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST,
enumspb.INDEXED_VALUE_TYPE_DATETIME:
stringVal, isString := val.(string)
if !isString {
return nil, fmt.Errorf("%w: expected string got %T", errUnexpectedJSONFieldType, val)
Expand Down
4 changes: 2 additions & 2 deletions common/searchattribute/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ var (

// predefined are internal search attributes which are passed and stored in SearchAttributes object together with custom search attributes.
predefined = map[string]enumspb.IndexedValueType{
TemporalChangeVersion: enumspb.INDEXED_VALUE_TYPE_KEYWORD,
BinaryChecksums: enumspb.INDEXED_VALUE_TYPE_KEYWORD,
TemporalChangeVersion: enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST,
BinaryChecksums: enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST,
BatcherNamespace: enumspb.INDEXED_VALUE_TYPE_KEYWORD,
BatcherUser: enumspb.INDEXED_VALUE_TYPE_KEYWORD,
TemporalScheduledStartTime: enumspb.INDEXED_VALUE_TYPE_DATETIME,
Expand Down
4 changes: 3 additions & 1 deletion common/searchattribute/encode_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ func DecodeValue(value *commonpb.Payload, t enumspb.IndexedValueType) (interface
// If search attribute value is `nil`, it means that search attribute needs to be removed from the document.

switch t {
case enumspb.INDEXED_VALUE_TYPE_TEXT, enumspb.INDEXED_VALUE_TYPE_KEYWORD:
case enumspb.INDEXED_VALUE_TYPE_TEXT,
enumspb.INDEXED_VALUE_TYPE_KEYWORD,
enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST:
var val *string
if err := payload.Decode(value, &val); err != nil {
var listVal []string
Expand Down
2 changes: 1 addition & 1 deletion common/searchattribute/name_type_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func Test_GetType(t *testing.T) {
assert.Equal(enumspb.INDEXED_VALUE_TYPE_KEYWORD, ivt)
ivt, err = typeMap.GetType("TemporalChangeVersion")
assert.NoError(err)
assert.Equal(enumspb.INDEXED_VALUE_TYPE_KEYWORD, ivt)
assert.Equal(enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST, ivt)
ivt, err = typeMap.GetType("NamespaceId")
assert.Error(err)
assert.Equal(enumspb.INDEXED_VALUE_TYPE_UNSPECIFIED, ivt)
Expand Down
8 changes: 6 additions & 2 deletions common/searchattribute/stringify.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ func parseValueTyped(valStr string, t enumspb.IndexedValueType) (interface{}, er
var err error

switch t {
case enumspb.INDEXED_VALUE_TYPE_TEXT, enumspb.INDEXED_VALUE_TYPE_KEYWORD:
case enumspb.INDEXED_VALUE_TYPE_TEXT,
enumspb.INDEXED_VALUE_TYPE_KEYWORD,
enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST:
val = valStr
case enumspb.INDEXED_VALUE_TYPE_INT:
val, err = strconv.ParseInt(valStr, 10, 64)
Expand Down Expand Up @@ -207,7 +209,9 @@ func isJsonArray(str string) bool {

func parseJsonArray(str string, t enumspb.IndexedValueType) (interface{}, error) {
switch t {
case enumspb.INDEXED_VALUE_TYPE_TEXT, enumspb.INDEXED_VALUE_TYPE_KEYWORD:
case enumspb.INDEXED_VALUE_TYPE_TEXT,
enumspb.INDEXED_VALUE_TYPE_KEYWORD,
enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST:
var result []string
err := json.Unmarshal([]byte(str), &result)
return result, err
Expand Down
2 changes: 1 addition & 1 deletion service/history/workflow/mutable_state_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@ func (ms *MutableStateImpl) addBinaryCheckSumIfNotExists(
exeInfo.AutoResetPoints = &workflowpb.ResetPoints{
Points: currResetPoints,
}
checksumsPayload, err := searchattribute.EncodeValue(recentBinaryChecksums, enumspb.INDEXED_VALUE_TYPE_KEYWORD)
checksumsPayload, err := searchattribute.EncodeValue(recentBinaryChecksums, enumspb.INDEXED_VALUE_TYPE_KEYWORD_LIST)
if err != nil {
return err
}
Expand Down