title: mongodb wildcard query from grails/groovy
body: <p>I’m having some problems with issuing a wildcard query in MongoDB from my Grails application.</p>
  
  <p>Basically the way I am doing it now is by issuing a <code>find</code> query with an array of query parameters:</p>
  
  <pre><code>db.log.find(criteria)    -&gt; where criteria is an array [testId:"test"]
  </code></pre>
  
  <p>This works fine as long as I’m strictly querying on actual values. However, for fun, I tried it with a wildcard search instead:</p>
  
  <pre><code>db.log.find(criteria) -&gt; this time critera = [testId:/.*te.*/]
  </code></pre>
  
  <p>This however will after looking at the Mongo query log as:</p>
  
  <pre><code> query: { query: { testId: "/.*te.*/" }
  </code></pre>
  
  <p>hence making the query not a wildcard search, but a query for this as a string, instead.
  Is there a way to work around this in some sense still using this concept of querying?</p>
  
  <p>Thanks in advance!</p>