Optional parameters in search template

I have search template with multiple parameters, while searching if the parameter value is empty string "" then filter applies in value with empty string "" returns 0 hits
for that reason i need optional parameter for if parameter not provided then search must ignore the filter , can any one help on it

I think you should do this before searching

For example, if you use php, you can use the following condition and if the condition is correct, do a search by Elasticsearch.

if($request != ''){
    // elasticsearch query
}