Will Elasticsearch optimize dsl query?

Hi there,
I have a program to convert some text into Elasticsearch dsl query. For some reasons it generates complex bool query which somethimes is actually can be simplified, for example:

{
    "query":{
        "bool":{
            "should":[
                {
                    "bool":{
                        "must":[
                            {
                                "bool":{
                                    "should":[
                                        {
                                            "multi_match":{
                                                "fields":[
                                                    "*"
                                                ],
                                                "query":"kid",
                                                "type":"best_fields"
                                            }
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

actually equals to:

{
    "query":{
        "bool":{
            "must":[
                {
                    "multi_match":{
                        "fields":[
                            "*"
                        ],
                        "query":"kid",
                        "type":"best_fields"
                    }
                }
            ]
        }
    }
}

So, will Elasticsearch itself handle this situation? If not, should I simplify it or not, considering query performance.
Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.