@@ -61,10 +61,22 @@ type SearchSource struct {
61
61
}
62
62
63
63
type SearchJSONSchema struct {
64
- Name string `json:"title,omitempty"`
65
- Description string `json:"description,omitempty"`
66
- Properties jsoniter.RawMessage `json:"properties,omitempty"`
67
- Source * SearchSource `json:"source,omitempty"`
64
+ Name string `json:"title,omitempty"`
65
+ Description string `json:"description,omitempty"`
66
+ Properties jsoniter.RawMessage `json:"properties,omitempty"`
67
+ Source * SearchSource `json:"source,omitempty"`
68
+ Options * SearchSchemaOptions `json:"options,omitempty"`
69
+ }
70
+
71
+ type SearchSchemaOptions struct {
72
+ TokenSeparators * []string `json:"token_separators,omitempty"`
73
+ }
74
+
75
+ func (s * SearchSchemaOptions ) GetTokenSeparators () []string {
76
+ if s .TokenSeparators == nil {
77
+ return make ([]string , 0 )
78
+ }
79
+ return * s .TokenSeparators
68
80
}
69
81
70
82
// SearchFactory is used as an intermediate step so that collection can be initialized with properly encoded values.
@@ -74,9 +86,10 @@ type SearchFactory struct {
74
86
// Fields are derived from the user schema.
75
87
Fields []* Field
76
88
// Schema is the raw JSON schema received
77
- Schema jsoniter.RawMessage
78
- Sub string
79
- Source SearchSource
89
+ Schema jsoniter.RawMessage
90
+ Sub string
91
+ Source SearchSource
92
+ Options SearchSchemaOptions
80
93
}
81
94
82
95
func (fb * FactoryBuilder ) BuildSearch (index string , reqSchema jsoniter.RawMessage ) (* SearchFactory , error ) {
@@ -120,12 +133,17 @@ func (fb *FactoryBuilder) BuildSearch(index string, reqSchema jsoniter.RawMessag
120
133
return nil , err
121
134
}
122
135
}
136
+ var schemaOptions SearchSchemaOptions
137
+ if schema .Options != nil {
138
+ schemaOptions = * schema .Options
139
+ }
123
140
124
141
factory := & SearchFactory {
125
- Name : index ,
126
- Fields : fields ,
127
- Schema : searchSchema ,
128
- Source : source ,
142
+ Name : index ,
143
+ Fields : fields ,
144
+ Schema : searchSchema ,
145
+ Source : source ,
146
+ Options : schemaOptions ,
129
147
}
130
148
131
149
idFound := false
@@ -181,6 +199,9 @@ type SearchIndex struct {
181
199
// will be one to one mapped to queryable field but complex fields like object type field there may be more than
182
200
// one queryableFields. As queryableFields represent a flattened state these can be used as-is to index in memory.
183
201
QueryableFields []* QueryableField
202
+ // TokenSeparators is a list of symbols or special characters to be used for splitting the text into individual
203
+ // words in addition to space and new-line characters.
204
+ TokenSeparators []string
184
205
// Source of this index
185
206
Source SearchSource
186
207
SearchIDField * QueryableField
@@ -198,12 +219,14 @@ func NewSearchIndex(ver uint32, searchStoreName string, factory *SearchFactory,
198
219
searchIdField = q
199
220
}
200
221
}
222
+
201
223
index := & SearchIndex {
202
224
Version : ver ,
203
225
Name : factory .Name ,
204
226
Fields : factory .Fields ,
205
227
Schema : factory .Schema ,
206
228
Source : factory .Source ,
229
+ TokenSeparators : factory .Options .GetTokenSeparators (),
207
230
SearchIDField : searchIdField ,
208
231
QueryableFields : queryableFields ,
209
232
int64FieldsPath : buildInt64Path (factory .Fields ),
@@ -330,6 +353,9 @@ func (s *SearchIndex) buildSearchSchema(name string) {
330
353
Name : name ,
331
354
Fields : tsFields ,
332
355
}
356
+ if len (s .TokenSeparators ) > 0 {
357
+ s .StoreSchema .TokenSeparators = & s .TokenSeparators
358
+ }
333
359
}
334
360
335
361
func (s * SearchIndex ) GetSearchDeltaFields (existingFields []* QueryableField , fieldsInSearch []tsApi.Field ) []tsApi.Field {
0 commit comments