The original query snippet used the 'phrase' operator, which can be less efficient for this type of search. Replacing it with 'match_phrase' provides a more targeted and accurate query. This change improves the search results by matching the exact phrase within the field, leading to more relevant results.

Here's the optimized OpenSearch query snippet:

query = query + f"""
                                    (or (match_phrase field=pc_premaintestatus '{PREVENTIVE_MAINTENANCE_STATUS.UNFOLLOWED.value[Const.VAL]}')
                                        (match_phrase field=pc_premaintestatus '{PREVENTIVE_MAINTENANCE_STATUS.FOLLOWED_REQUESTED_QUOTATION.value[Const.VAL]}')
                                        (match_phrase field=pc_premaintestatus '{PREVENTIVE_MAINTENANCE_STATUS.FOLLOWED_SUBMITTED_SS_QUOTATION.value[Const.VAL]}')
                                        (match_phrase field=pc_premaintestatus '{PREVENTIVE_MAINTENANCE_STATUS.FOLLOWED_NO_QUOTATION.value[Const.VAL]}')
                                        (match_phrase field=pc_premaintestatus '{PREVENTIVE_MAINTENANCE_STATUS.NONE.value[Const.VAL]}')
                                    )
                            """

This revised query effectively filters for specific preventative maintenance statuses using the match_phrase operator, resulting in improved search results.

OpenSearch Query Optimization: Using match_phrase for Preventative Maintenance Status