From cae9304ef3f3af0f19428c75951cd34f0f89204b Mon Sep 17 00:00:00 2001 From: Anil Maktala Date: Fri, 13 Sep 2024 13:50:45 -0400 Subject: [PATCH] fix: Add _type field only for OpenSearch version below 2.x --- .../streaming-lambda/python_streaming_function.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/amplify-graphql-searchable-transformer/streaming-lambda/python_streaming_function.py b/packages/amplify-graphql-searchable-transformer/streaming-lambda/python_streaming_function.py index c02487fb59..746992668a 100644 --- a/packages/amplify-graphql-searchable-transformer/streaming-lambda/python_streaming_function.py +++ b/packages/amplify-graphql-searchable-transformer/streaming-lambda/python_streaming_function.py @@ -215,8 +215,11 @@ def _lambda_handler(event, context): if is_ddb_insert_or_update: # Generate OpenSearch payload for item action = {'index': {'_index': doc_opensearch_index_name, - '_type': doc_type, '_id': doc_id}} + # Add _type field only for OpenSearch version below 2.x + if not OPENSEARCH_ENDPOINT.startswith('https://search-') or not OPENSEARCH_ENDPOINT.endswith('.es.amazonaws.com'): + # Assume OpenSearch version below 2.x + action['index']['_type'] = doc_type + "-_type" # Add external versioning if necessary if OPENSEARCH_USE_EXTERNAL_VERSIONING and '_version' in doc_fields: action['index'].update([