title: how do i filter my lucene search results?
body: <p>Say my requirement is</p>
  
  <pre><code>"search for all users by name, who are over 18"
  </code></pre>
  
  <p>If i were using SQL, i might write something like:</p>
  
  <pre><code>Select * from [Users]
  Where ([firstname] like '%' + @searchTerm + '%' OR 
         [lastname] like '%' + @searchTerm + '%')
      AND [age] &gt;= 18
  </code></pre>
  
  <p>However, im having difficulty translating this into lucene.net.</p>
  
  <p>This is what i have so far:</p>
  
  <pre><code>var parser = new MultiFieldQueryParser({ "firstname", "lastname"}, new StandardAnalyser());
  var luceneQuery = parser.Parse(searchterm)
  
  var query = FullTextSession.CreateFullTextQuery(luceneQuery, typeof(User));
  
  var results = query.List&lt;User&gt;();
  </code></pre>
  
  <p><b>How do i add in the "where age >= 18" bit?</b></p>
  
  <p>I've heard about <code>.SetFilter()</code>, but this only accepts LuceneQueries, and not IQueries. If <code>SetFilter</code> is the right thing to use, how do I make the appropriate filter? If not, what do I use and how do i do it?</p>
  
  <p>Thanks!</p>
  
  <p>P.S. This is a vastly simplified version of what I'm trying to do for clarity, my <code>WHERE</code> clause is actually a lot more complicated than shown here. In reality i need to check if ids exist in subqueries and check a number of unindexed properties. Any solutions given need to support this.</p>
  
  <p>Thanks</p>