Skip to content

Commit cb61966

Browse files
authored
Fix templates for OpenSearch 3.x by removing _doc mapping (#1301)
Fix template for OpenSearch 3.x by removing _doc mapping Signed-off-by: Phil Nguyen <nquangphuong@gmail.com>
1 parent dbd6cf3 commit cb61966

9 files changed

+99
-113
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
77
### Features
88
### Enhancements
99
### Bug Fixes
10+
- Fix substitution templates for OpenSearch 3.x compatibility by removing `_doc` mapping ([#1301](https://github.com/opensearch-project/flow-framework/pull/1301))
11+
1012
### Infrastructure
1113
### Documentation
1214
### Maintenance

src/main/resources/substitutionTemplates/hybrid-search-template.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,19 @@
4848
"index.search.default_pipeline": "${{create_search_pipeline.pipeline_id}}"
4949
},
5050
"mappings": {
51-
"_doc": {
52-
"properties": {
53-
"${{text_embedding.field_map.output}}": {
54-
"type": "knn_vector",
55-
"dimension": "${{text_embedding.field_map.output.dimension}}",
56-
"method": {
57-
"engine": "${{create_index.mappings.method.engine}}",
58-
"space_type": "${{create_index.mappings.method.space_type}}",
59-
"name": "${{create_index.mappings.method.name}}",
60-
"parameters": {}
61-
}
62-
},
63-
"${{text_embedding.field_map.input}}": {
64-
"type": "text"
51+
"properties": {
52+
"${{text_embedding.field_map.output}}": {
53+
"type": "knn_vector",
54+
"dimension": "${{text_embedding.field_map.output.dimension}}",
55+
"method": {
56+
"engine": "${{create_index.mappings.method.engine}}",
57+
"space_type": "${{create_index.mappings.method.space_type}}",
58+
"name": "${{create_index.mappings.method.name}}",
59+
"parameters": {}
6560
}
61+
},
62+
"${{text_embedding.field_map.input}}": {
63+
"type": "text"
6664
}
6765
}
6866
}

src/main/resources/substitutionTemplates/multi-modal-search-template.json

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,21 @@
4949
"number_of_shards": "${{create_index.settings.number_of_shards}}"
5050
},
5151
"mappings": {
52-
"_doc": {
53-
"properties": {
54-
"${{text_image_embedding.embedding}}": {
55-
"type": "knn_vector",
56-
"dimension": "${{text_image_embedding.field_map.output.dimension}}",
57-
"method": {
58-
"engine": "${{create_index.mappings.method.engine}}",
59-
"name": "${{create_index.mappings.method.name}}",
60-
"parameters": {}
61-
}
62-
},
63-
"${{text_image_embedding.field_map.text}}": {
64-
"type": "${{text_image_embedding.field_map.text.type}}"
65-
},
66-
"${{text_image_embedding.field_map.image}}": {
67-
"type": "${{text_image_embedding.field_map.image.type}}"
52+
"properties": {
53+
"${{text_image_embedding.embedding}}": {
54+
"type": "knn_vector",
55+
"dimension": "${{text_image_embedding.field_map.output.dimension}}",
56+
"method": {
57+
"engine": "${{create_index.mappings.method.engine}}",
58+
"name": "${{create_index.mappings.method.name}}",
59+
"parameters": {}
6860
}
61+
},
62+
"${{text_image_embedding.field_map.text}}": {
63+
"type": "${{text_image_embedding.field_map.text.type}}"
64+
},
65+
"${{text_image_embedding.field_map.image}}": {
66+
"type": "${{text_image_embedding.field_map.image.type}}"
6967
}
7068
}
7169
}

src/main/resources/substitutionTemplates/multi-modal-search-with-bedrock-titan-template.json

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"name": "${{register_remote_model.name}}",
5757
"function_name": "remote",
5858
"description": "${{register_remote_model.description}}",
59-
"deploy" : true
59+
"deploy": true
6060
}
6161
},
6262
{
@@ -99,23 +99,21 @@
9999
"number_of_shards": "${{create_index.settings.number_of_shards}}"
100100
},
101101
"mappings": {
102-
"_doc": {
103-
"properties": {
104-
"${{text_image_embedding.embedding}}": {
105-
"type": "knn_vector",
106-
"dimension": "${{text_image_embedding.field_map.output.dimension}}",
107-
"method": {
108-
"engine": "${{create_index.mappings.method.engine}}",
109-
"name": "${{create_index.mappings.method.name}}",
110-
"parameters": {}
111-
}
112-
},
113-
"${{text_image_embedding.field_map.text}}": {
114-
"type": "${{text_image_embedding.field_map.text.type}}"
115-
},
116-
"${{text_image_embedding.field_map.image}}": {
117-
"type": "${{text_image_embedding.field_map.image.type}}"
102+
"properties": {
103+
"${{text_image_embedding.embedding}}": {
104+
"type": "knn_vector",
105+
"dimension": "${{text_image_embedding.field_map.output.dimension}}",
106+
"method": {
107+
"engine": "${{create_index.mappings.method.engine}}",
108+
"name": "${{create_index.mappings.method.name}}",
109+
"parameters": {}
118110
}
111+
},
112+
"${{text_image_embedding.field_map.text}}": {
113+
"type": "${{text_image_embedding.field_map.text.type}}"
114+
},
115+
"${{text_image_embedding.field_map.image}}": {
116+
"type": "${{text_image_embedding.field_map.image.type}}"
119117
}
120118
}
121119
}

src/main/resources/substitutionTemplates/neural-sparse-local-biencoder-template.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@
5959
"default_pipeline": "${{create_ingest_pipeline.pipeline_id}}"
6060
},
6161
"mappings": {
62-
"_doc": {
63-
"properties": {
64-
"${{create_ingest_pipeline.text_embedding.field_map.output}}": {
65-
"type": "rank_features"
66-
},
67-
"${{create_ingest_pipeline.text_embedding.field_map.input}}": {
68-
"type": "text"
69-
}
62+
"properties": {
63+
"${{create_ingest_pipeline.text_embedding.field_map.output}}": {
64+
"type": "rank_features"
65+
},
66+
"${{create_ingest_pipeline.text_embedding.field_map.input}}": {
67+
"type": "text"
7068
}
7169
}
7270
}

src/main/resources/substitutionTemplates/semantic-search-template.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,19 @@
4747
"number_of_shards": "${{create_index.settings.number_of_shards}}"
4848
},
4949
"mappings": {
50-
"_doc": {
51-
"properties": {
52-
"${{text_embedding.field_map.output}}": {
53-
"type": "knn_vector",
54-
"dimension": "${{text_embedding.field_map.output.dimension}}",
55-
"method": {
56-
"engine": "${{create_index.mappings.method.engine}}",
57-
"space_type": "${{create_index.mappings.method.space_type}}",
58-
"name": "${{create_index.mappings.method.name}}",
59-
"parameters": {}
60-
}
61-
},
62-
"${{text_embedding.field_map.input}}": {
63-
"type": "text"
50+
"properties": {
51+
"${{text_embedding.field_map.output}}": {
52+
"type": "knn_vector",
53+
"dimension": "${{text_embedding.field_map.output.dimension}}",
54+
"method": {
55+
"engine": "${{create_index.mappings.method.engine}}",
56+
"space_type": "${{create_index.mappings.method.space_type}}",
57+
"name": "${{create_index.mappings.method.name}}",
58+
"parameters": {}
6459
}
60+
},
61+
"${{text_embedding.field_map.input}}": {
62+
"type": "text"
6563
}
6664
}
6765
}

src/main/resources/substitutionTemplates/semantic-search-with-model-and-query-enricher-template.json

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,19 @@
9797
"index.search.default_pipeline": "${{create_search_pipeline.pipeline_id}}"
9898
},
9999
"mappings": {
100-
"_doc": {
101-
"properties": {
102-
"${{text_embedding.field_map.output}}": {
103-
"type": "knn_vector",
104-
"dimension": "${{text_embedding.field_map.output.dimension}}",
105-
"method": {
106-
"engine": "${{create_index.mappings.method.engine}}",
107-
"space_type": "${{create_index.mappings.method.space_type}}",
108-
"name": "${{create_index.mappings.method.name}}",
109-
"parameters": {}
110-
}
111-
},
112-
"${{text_embedding.field_map.input}}": {
113-
"type": "text"
100+
"properties": {
101+
"${{text_embedding.field_map.output}}": {
102+
"type": "knn_vector",
103+
"dimension": "${{text_embedding.field_map.output.dimension}}",
104+
"method": {
105+
"engine": "${{create_index.mappings.method.engine}}",
106+
"space_type": "${{create_index.mappings.method.space_type}}",
107+
"name": "${{create_index.mappings.method.name}}",
108+
"parameters": {}
114109
}
110+
},
111+
"${{text_embedding.field_map.input}}": {
112+
"type": "text"
115113
}
116114
}
117115
}
@@ -129,7 +127,7 @@
129127
"configurations": {
130128
"request_processors": [
131129
{
132-
"neural_query_enricher" : {
130+
"neural_query_enricher": {
133131
"description": "Sets the default model ID at index and field levels",
134132
"default_model_id": "${{register_model.model_id}}"
135133
}

src/main/resources/substitutionTemplates/semantic-search-with-model-template.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,19 @@
9696
"number_of_shards": "${{create_index.settings.number_of_shards}}"
9797
},
9898
"mappings": {
99-
"_doc": {
100-
"properties": {
101-
"${{text_embedding.field_map.output}}": {
102-
"type": "knn_vector",
103-
"dimension": "${{text_embedding.field_map.output.dimension}}",
104-
"method": {
105-
"engine": "${{create_index.mappings.method.engine}}",
106-
"space_type": "${{create_index.mappings.method.space_type}}",
107-
"name": "${{create_index.mappings.method.name}}",
108-
"parameters": {}
109-
}
110-
},
111-
"${{text_embedding.field_map.input}}": {
112-
"type": "text"
99+
"properties": {
100+
"${{text_embedding.field_map.output}}": {
101+
"type": "knn_vector",
102+
"dimension": "${{text_embedding.field_map.output.dimension}}",
103+
"method": {
104+
"engine": "${{create_index.mappings.method.engine}}",
105+
"space_type": "${{create_index.mappings.method.space_type}}",
106+
"name": "${{create_index.mappings.method.name}}",
107+
"parameters": {}
113108
}
109+
},
110+
"${{text_embedding.field_map.input}}": {
111+
"type": "text"
114112
}
115113
}
116114
}

src/main/resources/substitutionTemplates/semantic-search-with-query-enricher-template.json

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"configurations": {
4141
"request_processors": [
4242
{
43-
"neural_query_enricher" : {
43+
"neural_query_enricher": {
4444
"description": "Sets the default model ID at index and field levels",
4545
"default_model_id": "${{create_ingest_pipeline.model_id}}"
4646
}
@@ -65,21 +65,19 @@
6565
"index.search.default_pipeline": "${{create_search_pipeline.pipeline_id}}"
6666
},
6767
"mappings": {
68-
"_doc": {
69-
"properties": {
70-
"${{text_embedding.field_map.output}}": {
71-
"type": "knn_vector",
72-
"dimension": "${{text_embedding.field_map.output.dimension}}",
73-
"method": {
74-
"engine": "${{create_index.mappings.method.engine}}",
75-
"space_type": "${{create_index.mappings.method.space_type}}",
76-
"name": "${{create_index.mappings.method.name}}",
77-
"parameters": {}
78-
}
79-
},
80-
"${{text_embedding.field_map.input}}": {
81-
"type": "text"
68+
"properties": {
69+
"${{text_embedding.field_map.output}}": {
70+
"type": "knn_vector",
71+
"dimension": "${{text_embedding.field_map.output.dimension}}",
72+
"method": {
73+
"engine": "${{create_index.mappings.method.engine}}",
74+
"space_type": "${{create_index.mappings.method.space_type}}",
75+
"name": "${{create_index.mappings.method.name}}",
76+
"parameters": {}
8277
}
78+
},
79+
"${{text_embedding.field_map.input}}": {
80+
"type": "text"
8381
}
8482
}
8583
}

0 commit comments

Comments
 (0)