@@ -34,6 +34,7 @@ import {
34
34
NEURAL_SPARSE_TOKENIZER_TRANSFORMER ,
35
35
REGISTER_LOCAL_SPARSE_ENCODING_MODEL_STEP_TYPE ,
36
36
SparseEncodingProcessor ,
37
+ IndexMappings ,
37
38
} from '../../../../common' ;
38
39
39
40
/**
@@ -266,20 +267,12 @@ function indexerToTemplateNode(
266
267
directlyConnectedNode ,
267
268
] ) ;
268
269
269
- return {
270
- id : flowNode . data . id ,
271
- type : CREATE_INDEX_STEP_TYPE ,
272
- previous_node_inputs : {
273
- [ directlyConnectedNode . id ] : 'pipeline_id' ,
274
- } ,
275
- user_inputs : {
276
- index_name : indexName ,
277
- configurations : {
278
- settings : {
279
- default_pipeline : `\${{${ directlyConnectedNode . id } .pipeline_id}}` ,
280
- } ,
281
- mappings : {
282
- properties : {
270
+ // index mappings are different per use case
271
+ const finalIndexMappings = {
272
+ properties :
273
+ directlyConnectedNode . data . type ===
274
+ COMPONENT_CLASS . TEXT_EMBEDDING_TRANSFORMER
275
+ ? {
283
276
[ vectorField ] : {
284
277
type : 'knn_vector' ,
285
278
// TODO: remove hardcoding, fetch from the selected model
@@ -295,8 +288,30 @@ function indexerToTemplateNode(
295
288
[ inputField ] : {
296
289
type : 'text' ,
297
290
} ,
291
+ }
292
+ : {
293
+ [ vectorField ] : {
294
+ type : 'rank_features' ,
295
+ } ,
296
+ [ inputField ] : {
297
+ type : 'text' ,
298
+ } ,
298
299
} ,
300
+ } as IndexMappings ;
301
+
302
+ return {
303
+ id : flowNode . data . id ,
304
+ type : CREATE_INDEX_STEP_TYPE ,
305
+ previous_node_inputs : {
306
+ [ directlyConnectedNode . id ] : 'pipeline_id' ,
307
+ } ,
308
+ user_inputs : {
309
+ index_name : indexName ,
310
+ configurations : {
311
+ settings : {
312
+ default_pipeline : `\${{${ directlyConnectedNode . id } .pipeline_id}}` ,
299
313
} ,
314
+ mappings : finalIndexMappings ,
300
315
} ,
301
316
} ,
302
317
} ;
0 commit comments