title: Ask for a design pattern
body: <p>We are working on web application with a search model.</p>
  
  <p>In the search servlet it capture the request parameters from the client, and then build a hibernate-search query for searching.</p>
  
  <p>Now the problem is the parameters from the client are mutable!.</p>
  
  <p>All the parameters we accepts are listed as following:</p>
  
  <p>1) keyword.</p>
  
  <p>The keyword(s) using for searching,a search request can be processed even just this parameter is passed.</p>
  
  <p>Valid example:</p>
  
  <pre><code>/search?keyword="test"
  </code></pre>
  
  <p>2) lowleftX,lowleftY,upperrightX,upperrightY.</p>
  
  <p>These four parameter must occur at the same time or never.Since these four paramers are used for a TermRangeQuery in lucene. If one of them occur,the rest three must be occur also.</p>
  
  <p>And, these four parameter can occur with the "keyword" at the sametime.</p>
  
  <p>Valid example:</p>
  
  <pre><code>/search?lowleftX=10&amp;lowleftY=10&amp;upperrightX=40&amp;upperrightY=30
  /search?lowleftX=10&amp;lowleftY=10&amp;upperrightX=40&amp;upperrightY=30&amp;keyword="test"
  </code></pre>
  
  <p>3) category</p>
  
  <p>This is used to limit the search scope(just search within the special category).</p>
  
  <p>4) start,limit</p>
  
  <p>These two parameters are using for paging.</p>
  
  <p>5) returnFields</p>
  
  <p>The returnFields which will be retrieved from the index (if it is stored in the index) and return to the client.</p>
  
  <p>So I have no idea about how to build the query using the estimate syntax (if....else....if...).</p>
  
  <p>Can anyone tell me how ?</p>