title: how to create query parser to parse query param in spring REST
body: <p>My query parameter is like this:</p>
  
  <pre><code>q=name:abc+age:20+roleid:(23|45)|audeince:(23|24).Here + is for AND | is for OR
  </code></pre>
  
  <p>I have to accept this query param as it is into my spring controller and have to make query to solar to fetch the data.</p>
  
  <p>￼</p>
  
  <pre><code>@Controller
  @RequestMapping("/user")
  public class BooksController {
   @RequestMapping(value="/details", method=RequestMethod.GET)
  public ResponseEntity&lt;?&gt; getUser(final HttpServletRequest request) {
  
    String params = requestParams.get("q")[0];
      //passing this string to make query in apache solar
  }
  }
  </code></pre>
  
  <p>I need to write a parser to split the param value to make a solar query.how to write a query parser to split the above url to make solar query satisfying OR AND condition.name:abc+age:20+roleid:(23|45)|audeince:(23|24) means create a solar query where name=abc and age=20 and roleid in (23,24) or audience in (23,24) .This way user sends query.</p>
  
  <p>Eg:firstName:(abc|bcd)+lastName:abc+emailId:abc+dsID:abc|countryCd:US+audienceId:(123+678)</p>
  
  <p>first using regex convert like this 
  firstName:(abc|bcd)+  -----------segment1</p>
  
  <p>lastName:abc+.............segment2</p>
  
  <p>emailId:abc+.............segment3</p>
  
  <p>dsID:abc|--------------segment4</p>
  
  <p>countryCd:US+----------segment5</p>
  
  <p>audienceId:(123+678)------segment 6;</p>
  
  <p>like many segments may come in  the url </p>
  
  <p>i have a class   called </p>
  
  <p>class Queryobj{</p>
  
  <p>private String  field;</p>
  
  <p>private List value;</p>
  
  <p>private String internalOperator;</p>
  
  <p>private String externalOperator;</p>
  
  <p>}</p>
  
  <p>firstName:(abc|bcd)+ again using regex map Like this</p>
  
  <p>field=firstName</p>
  
  <p>value={abc,bcd}</p>
  
  <p>internalOperator=|</p>
  
  <p>externalOperator=+</p>
  
  <p>like second segment  emailId:abc+</p>
  
  <p>field=emailId</p>
  
  <p>value=abc</p>
  
  <p>internalOperator=null</p>
  
  <p>externalOperator=+</p>
  
  <p>same for other segments also .if there are n segments we have n objects.</p>
  
  <p>After that add each object to Linked List.if internalOperator or externalOperator is null then leave it as null .How can I achieve that</p>