$main_hash{"query"}{"filtered"}{"query"}{"bool"}{"must"} = \@file_array; $main_hash{"query"}{"filtered"}{"filter"} = $condition_array[(int($condition)-1)]; #### { "query": { "filtered": { "query": { "bool": { "must": [ {"wildcard": { "path": "/home/GEMS/CDRS/Delivery/ravi_16051820*.log" } } ] } }, "filter": { "bool": { "should": [ { "term": { "OrigInterface": "SMPP" } }, { "term": { "OrigInterface": "SMPP" } } ] } } } } } #### { "query": { "filtered": { "filter": { "bool": { "should": [ { "term": { "OrigInterface": "SMPP" } }, { "term": { "OrigInterface": "SMPP" } } ] } }, "query": { "bool": { "must": [ {"wildcard": { "path": "/home/GEMS/CDRS/Delivery/ravi_16051820*.log" } } ] } } } } }