title: How to use regex for querying in Solr 4
body: <p>I've reached the point of desperation, so I'm asking for help. I'm trying to query results from a Solr 4 engine using regex.</p>
  
  <p>Let's asume the document I want to query is:</p>
  
  <pre><code>&lt;str name="text"&gt;description: best company; name: roca mola&lt;/str&gt;
  </code></pre>
  
  <p>And I want to query using this regex:</p>
  
  <pre><code>description:(.*)?company(.*)?;
  </code></pre>
  
  <p>I read in some <a href="http://lucene.472066.n3.nabble.com/Solr-Use-Regex-in-the-Query-Phrase-td4015335.html" rel="noreferrer">forums</a> that using regex in Solr 4 was as easy as adding slashes, like:</p>
  
  <pre><code>localhost:8080/solr/q=text:/description\:(.*)?company(.*)?;/
  </code></pre>
  
  <p>but it isn't working. And this one doesn't work either:</p>
  
  <pre><code>localhost:8080/solr/q=text:/description(.*)?company(.*)?;/
  </code></pre>
  
  <p>I don't want a simple query like:</p>
  
  <pre><code>localhost:8080/solr/q=text:*company*
  </code></pre>
  
  <p>Since that would mismatch documents like:</p>
  
  <pre><code>&lt;str name="text"&gt;description: my home; name: mother company"&lt;/str&gt;
  </code></pre>
  
  <p>If I'm not clear please let me know.</p>
  
  <p>Cheers from Chile :D</p>
  
  <p><strong>NOTE</strong>: I was using <code>text_general</code> fields on my scheme. As @arun pointed out, <code>string</code> fields can handle the type of regex I'm using.</p>