[OpenSearch] Static Mapping Question

1

Hi, We are planning to create a static mapping template in OpenSearch. Just want to know few things:

  1. Will the static mapping help us on query performance? (such as reduce searching latency)
  2. Will the static mapping help us on reduce resource usage? (CPU, RAM, ...)
  3. Since our upstream add new attributes in the incoming records over time, so we will keep the mappings -> dynamic to true in our _index_template, and only add part of all incoming attributes in the mapping template. In this case, will static mapping help in terms of performance?

Thanks, Frank

Frank
asked 2 months ago427 views
1 Answer
2
Accepted Answer

Hello Frank,

Regarding to your questions :-

  1. Will the static mapping help us on query performance? (such as reduce searching latency)

Yes, defining static mappings can improve query performance. By specifying the data types Prior specification of data types and index configurations helps OpenSearch to remove load of determination the data type and help in query performance and help reduce indexing latency.

  1. Will the static mapping help us on reduce resource usage? (CPU, RAM, ...)

Yes, again as per 1 it will decrease the query time which help decreasing the CPU but not to a great extent. However, the indexing and searching overhead savings are usually marginal.

  1. Since our upstream add new attributes in the incoming records over time, so we will keep the mappings -> dynamic to true in our _index_template, and only add part of all incoming attributes in the mapping template. In this case, will static mapping help in terms of performance?

If you are keeping mappings dynamic to true to accommodate new fields being added, some of the performance benefits of static mappings are reduced. However, for the fields defined statically upfront, you will still see faster indexing and better query execution. This is because data types and index parameters are pre-configured for those known fields.

REF :- [+] https://opensearch.org/docs/latest/field-types/#explicit-mapping [+] Troubleshoot search latency spikes -- https://repost.aws/knowledge-center/opensearch-latency-spikes [+] https://opensearch.org/docs/1.3/api-reference/index-apis/create-index/#static-index-settings

So in summary - even with dynamic mappings enabled, having some portion of expected fields defined in a static template is beneficial. It saves resources for those known fields. Just ensure the static and dynamic mapped fields don't conflict in data types defined. The static mappings boost performance, but dynamic mappings provide flexibility.

Feel free to reply if you need any further information.

Thank you!

AWS
SUPPORT ENGINEER
answered 2 months ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions