title: Advanced search REST API
body: <p>My requirement is to implement advanced search Rest API for searching the phones. The URI for the search API is <a href="http://myservice/api/v1/phones/search?q=" rel="noreferrer">http://myservice/api/v1/phones/search?q=</a>${query_expression}</p>
  
  <p>Where <em>q</em> is the complex query expression. Have the following questions </p>
  
  <p>1) Since advanced search involves a lengthy query expression, the URI will not fit in a GET call. Is it alright to implement the search API via POST request and still maintain the RESTfulness?</p>
  
  <p>2) I have come across the following implementations for the advanced search:</p>
  
  <ul>
  <li>1st approach -  Send the complete infix expression for the query expression.
   eg.</li>
  </ul>
  
  <p><code>PHONENAME STARTSWITH 'AR' AND ( PHONETYPE = '4G' OR PHONECOLOR = 'RED')</code></p>
  
  <ul>
  <li><p>2nd approach - Constructing entire query expression in the form of a json.
  eg.   </p>
  
  <p><code>{"criteria":[
      {"index":1,"field":"PHONENAME","value":"AR","comparator":"STARTSWITH"},
      {"index":2,"field":"PHONETYPE","value":"4G","comparator":"EQUALS"},
      {"index":3,"field":"PHONECOLOR","value":"RED","comparator":"EQUALS"}
  ],"criteria":"( 1 AND (2  OR 3) )"}</code></p></li>
  <li><p>3rd approach - Alternative way to implement the query expression as a json.
  eg.</p>
  
  <p><code>{"and":[
      {"field":"PHONENAME","value":"AR","comparator":"STARTSWITH"},
      "or":[
      {"field":"PHONETYPE","value":"4G","comparator":"EQUALS"},
      {"field":"PHONECOLOR","value":"RED","comparator":"EQUALS"}]
  ]}</code></p></li>
  </ul>
  
  <p>Which approach would be considered more RESTful out of the three? Suggestions for any other approaches are welcome :)</p>