Thoughts
What did I say about Ruby programmers and bad regular expressions?
Elasticsearch has a `wildcard` option why are you using a series of regular expressions to transform the input query into a regular expression?
> regex = regex.gsub(/(?<!\\)%/, ".*").gsub(/(?<!\\)_/, ".").gsub("\\%", "%").gsub("\\_", "_")