File tree Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { CreateNoticeOptions , CreateNoticeResult } from '../../src/modules/cls/interface' ;
2
2
import { ClsNotice } from '../../src' ;
3
3
4
- describe ( 'Cls Alarm ' , ( ) => {
4
+ describe ( 'Cls Notice ' , ( ) => {
5
5
const credentials = {
6
6
SecretId : process . env . TENCENT_SECRET_ID ,
7
7
SecretKey : process . env . TENCENT_SECRET_KEY ,
Original file line number Diff line number Diff line change @@ -152,15 +152,34 @@ export default class Cls {
152
152
153
153
// 更新索引
154
154
async deployIndex ( inputs : DeployIndexInputs ) {
155
- if ( inputs . rule ) {
155
+ if ( inputs . indexRule ) {
156
156
console . log ( 'Deploying index' ) ;
157
157
158
+ const { fullText, keyValue } = inputs . indexRule ! ;
159
+ let parsedFullText ;
160
+ let parsedKeyValue : any ;
161
+ if ( fullText ) {
162
+ parsedFullText = {
163
+ case_sensitive : fullText . caseSensitive ,
164
+ tokenizer : fullText . tokenizer ,
165
+ } ;
166
+ parsedKeyValue = {
167
+ case_sensitive : keyValue ?. caseSensitive ! ,
168
+ keys : keyValue ?. keys ?. map ( ( v ) => v . key ) ?? [ ] ,
169
+ types : keyValue ?. keys ?. map ( ( v ) => v . type ) ?? [ ] ,
170
+ sql_flags : keyValue ?. keys ?. map ( ( v ) => v . sqlFlag ) ?? [ ] ,
171
+ tokenizers : keyValue ?. keys . map ( ( v ) => v . tokenizer ) ?? [ ] ,
172
+ } ;
173
+ }
158
174
try {
159
175
await updateIndex ( this . clsClient , {
160
176
topicId : inputs . topicId ! ,
161
177
// FIXME: effective is always true in updateIndex
162
178
effective : inputs . effective !== false ? true : false ,
163
- rule : inputs . rule ,
179
+ rule : {
180
+ full_text : parsedFullText ,
181
+ key_value : parsedKeyValue ,
182
+ } ,
164
183
} ) ;
165
184
} catch ( err ) {
166
185
console . log ( '' + err ) ;
Original file line number Diff line number Diff line change 1
- import { IndexRule } from '@tencent-sdk/cls/dist/typings' ;
2
1
import { RegionType , CamelCasedProps } from './../interface' ;
3
2
import { DeployDashboardInputs } from './dashboard' ;
4
3
@@ -162,7 +161,21 @@ export interface DeployTopicInputs {
162
161
export interface DeployIndexInputs {
163
162
topicId ?: string ;
164
163
effective ?: boolean ;
165
- rule ?: IndexRule ;
164
+ indexRule ?: {
165
+ fullText : {
166
+ caseSensitive : boolean ;
167
+ tokenizer : string ;
168
+ } ;
169
+ keyValue ?: {
170
+ caseSensitive : boolean ;
171
+ keys : {
172
+ key : string ;
173
+ type : string ;
174
+ sqlFlag : boolean ;
175
+ tokenizer : string ;
176
+ } [ ] ;
177
+ } ;
178
+ } ;
166
179
}
167
180
168
181
export interface AlarmInputs {
You can’t perform that action at this time.
0 commit comments