@@ -9,11 +9,17 @@ import (
99
1010type (
1111 SearchAttribute struct {
12- key string
13- // alias refers to a fully formed schema field, which is either a Predefined or CHASM search attribute
14- alias string
12+ // alias refers to the user defined name of the search attribute
13+ alias string
14+ // field refers to a fully formed schema field, which is either a Predefined or CHASM search attribute
15+ field string
1516 valueType enumspb.IndexedValueType
16- value any
17+ }
18+
19+ SearchAttributeKeyValue struct {
20+ alias string
21+ field string
22+ value VisibilityValue
1723 }
1824
1925 SearchAttributeBool struct {
@@ -64,165 +70,185 @@ func ResolveFieldName(valueType enumspb.IndexedValueType, index int) string {
6470 }
6571}
6672
67- // GetKey returns the search attribute key.
68- func (s * SearchAttribute ) GetKey () string {
69- return s .key
70- }
71-
72- // GetAlias returns the search attribute alias (field name).
73+ // GetAlias returns the search attribute alias.
7374func (s * SearchAttribute ) GetAlias () string {
7475 return s .alias
7576}
7677
78+ // GetField returns the search attribute field name.
79+ func (s * SearchAttribute ) GetField () string {
80+ return s .field
81+ }
82+
7783// GetValueType returns the indexed value type.
7884func (s * SearchAttribute ) GetValueType () enumspb.IndexedValueType {
7985 return s .valueType
8086}
8187
82- // GetValue returns the search attribute value.
83- func (s * SearchAttribute ) GetValue () any {
84- return s .value
85- }
86-
87- func NewSearchAttributeBoolByIndex (key string , index int ) * SearchAttributeBool {
88+ func NewSearchAttributeBoolByIndex (alias string , index int ) * SearchAttributeBool {
8889 return & SearchAttributeBool {
8990 SearchAttribute : SearchAttribute {
90- key : key ,
91- alias : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_BOOL , index ),
91+ alias : alias ,
92+ field : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_BOOL , index ),
9293 valueType : enumspb .INDEXED_VALUE_TYPE_BOOL ,
9394 },
9495 }
9596}
9697
97- func NewSearchAttributeBoolByAlias (key string , alias string ) * SearchAttributeBool {
98+ func NewSearchAttributeBoolByAlias (alias string , field string ) * SearchAttributeBool {
9899 return & SearchAttributeBool {
99100 SearchAttribute : SearchAttribute {
100- key : key ,
101101 alias : alias ,
102+ field : field ,
102103 valueType : enumspb .INDEXED_VALUE_TYPE_BOOL ,
103104 },
104105 }
105106}
106107
107- func (s * SearchAttributeBool ) SetValue (value bool ) {
108- s .value = value
108+ func (s SearchAttributeBool ) SetValue (value bool ) SearchAttributeKeyValue {
109+ return SearchAttributeKeyValue {
110+ alias : s .alias ,
111+ field : s .field ,
112+ value : VisibilityValueBool (value ),
113+ }
109114}
110115
111- func NewSearchAttributeTimeByIndex (key string , index int ) * SearchAttributeTime {
116+ func NewSearchAttributeTimeByIndex (alias string , index int ) * SearchAttributeTime {
112117 return & SearchAttributeTime {
113118 SearchAttribute : SearchAttribute {
114- key : key ,
115- alias : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_DATETIME , index ),
119+ alias : alias ,
120+ field : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_DATETIME , index ),
116121 valueType : enumspb .INDEXED_VALUE_TYPE_DATETIME ,
117122 },
118123 }
119124}
120125
121- func NewSearchAttributeTimeByAlias (key string , alias string ) * SearchAttributeTime {
126+ func NewSearchAttributeTimeByAlias (alias string , field string ) * SearchAttributeTime {
122127 return & SearchAttributeTime {
123128 SearchAttribute : SearchAttribute {
124- key : key ,
125129 alias : alias ,
130+ field : field ,
126131 valueType : enumspb .INDEXED_VALUE_TYPE_DATETIME ,
127132 },
128133 }
129134}
130135
131- func (s * SearchAttributeTime ) SetValue (value time.Time ) {
132- s .value = value
136+ func (s SearchAttributeTime ) SetValue (value time.Time ) SearchAttributeKeyValue {
137+ return SearchAttributeKeyValue {
138+ alias : s .alias ,
139+ field : s .field ,
140+ value : VisibilityValueTime (value ),
141+ }
133142}
134143
135- func NewSearchAttributeFloat64ByIndex (key string , index int ) * SearchAttributeFloat64 {
144+ func NewSearchAttributeFloat64ByIndex (alias string , index int ) * SearchAttributeFloat64 {
136145 return & SearchAttributeFloat64 {
137146 SearchAttribute : SearchAttribute {
138- key : key ,
139- alias : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_DOUBLE , index ),
147+ alias : alias ,
148+ field : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_DOUBLE , index ),
140149 valueType : enumspb .INDEXED_VALUE_TYPE_DOUBLE ,
141150 },
142151 }
143152}
144153
145- func NewSearchAttributeFloat64ByAlias (key string , alias string ) * SearchAttributeFloat64 {
154+ func NewSearchAttributeFloat64ByAlias (alias string , field string ) * SearchAttributeFloat64 {
146155 return & SearchAttributeFloat64 {
147156 SearchAttribute : SearchAttribute {
148- key : key ,
149157 alias : alias ,
158+ field : field ,
150159 valueType : enumspb .INDEXED_VALUE_TYPE_DOUBLE ,
151160 },
152161 }
153162}
154163
155- func (s * SearchAttributeFloat64 ) SetValue (value float64 ) {
156- s .value = value
164+ func (s SearchAttributeFloat64 ) SetValue (value float64 ) SearchAttributeKeyValue {
165+ return SearchAttributeKeyValue {
166+ alias : s .alias ,
167+ field : s .field ,
168+ value : VisibilityValueFloat64 (value ),
169+ }
157170}
158171
159- func NewSearchAttributeKeywordByIndex (key string , index int ) * SearchAttributeKeyword {
172+ func NewSearchAttributeKeywordByIndex (alias string , index int ) * SearchAttributeKeyword {
160173 return & SearchAttributeKeyword {
161174 SearchAttribute : SearchAttribute {
162- key : key ,
163- alias : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_KEYWORD , index ),
175+ alias : alias ,
176+ field : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_KEYWORD , index ),
164177 valueType : enumspb .INDEXED_VALUE_TYPE_KEYWORD ,
165178 },
166179 }
167180}
168181
169- func NewSearchAttributeKeywordByAlias (key string , alias string ) * SearchAttributeKeyword {
182+ func NewSearchAttributeKeywordByAlias (alias string , field string ) * SearchAttributeKeyword {
170183 return & SearchAttributeKeyword {
171184 SearchAttribute : SearchAttribute {
172- key : key ,
173185 alias : alias ,
186+ field : field ,
174187 valueType : enumspb .INDEXED_VALUE_TYPE_KEYWORD ,
175188 },
176189 }
177190}
178191
179- func (s * SearchAttributeKeyword ) SetValue (value string ) {
180- s .value = value
192+ func (s SearchAttributeKeyword ) SetValue (value string ) SearchAttributeKeyValue {
193+ return SearchAttributeKeyValue {
194+ alias : s .alias ,
195+ field : s .field ,
196+ value : VisibilityValueString (value ),
197+ }
181198}
182199
183- func NewSearchAttributeTextByIndex (key string , index int ) * SearchAttributeText {
200+ func NewSearchAttributeTextByIndex (alias string , index int ) * SearchAttributeText {
184201 return & SearchAttributeText {
185202 SearchAttribute : SearchAttribute {
186- key : key ,
187- alias : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_TEXT , index ),
203+ alias : alias ,
204+ field : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_TEXT , index ),
188205 valueType : enumspb .INDEXED_VALUE_TYPE_TEXT ,
189206 },
190207 }
191208}
192209
193- func NewSearchAttributeTextByAlias (key string , alias string ) * SearchAttributeText {
210+ func NewSearchAttributeTextByAlias (alias string , field string ) * SearchAttributeText {
194211 return & SearchAttributeText {
195212 SearchAttribute : SearchAttribute {
196- key : key ,
197213 alias : alias ,
214+ field : field ,
198215 valueType : enumspb .INDEXED_VALUE_TYPE_TEXT ,
199216 },
200217 }
201218}
202- func (s * SearchAttributeText ) SetValue (value string ) {
203- s .value = value
219+
220+ func (s SearchAttributeText ) SetValue (value string ) SearchAttributeKeyValue {
221+ return SearchAttributeKeyValue {
222+ alias : s .alias ,
223+ field : s .field ,
224+ value : VisibilityValueString (value ),
225+ }
204226}
205227
206- func NewSearchAttributeKeywordListByIndex (key string , index int ) * SearchAttributeKeywordList {
228+ func NewSearchAttributeKeywordListByIndex (alias string , index int ) * SearchAttributeKeywordList {
207229 return & SearchAttributeKeywordList {
208230 SearchAttribute : SearchAttribute {
209- key : key ,
210- alias : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_KEYWORD_LIST , index ),
231+ alias : alias ,
232+ field : ResolveFieldName (enumspb .INDEXED_VALUE_TYPE_KEYWORD_LIST , index ),
211233 valueType : enumspb .INDEXED_VALUE_TYPE_KEYWORD_LIST ,
212234 },
213235 }
214236}
215237
216- func NewSearchAttributeKeywordListByAlias (key string , alias string ) * SearchAttributeKeywordList {
238+ func NewSearchAttributeKeywordListByAlias (alias string , field string ) * SearchAttributeKeywordList {
217239 return & SearchAttributeKeywordList {
218240 SearchAttribute : SearchAttribute {
219- key : key ,
220241 alias : alias ,
242+ field : field ,
221243 valueType : enumspb .INDEXED_VALUE_TYPE_KEYWORD_LIST ,
222244 },
223245 }
224246}
225247
226- func (s * SearchAttributeKeywordList ) SetValue (value []string ) {
227- s .value = value
248+ func (s SearchAttributeKeywordList ) SetValue (value []string ) SearchAttributeKeyValue {
249+ return SearchAttributeKeyValue {
250+ alias : s .alias ,
251+ field : s .field ,
252+ value : VisibilityValueStringSlice (value ),
253+ }
228254}
0 commit comments