<div dir="ltr">Open an issue for tracking and propose a solution.<div><br></div><div>-aslak-</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 10, 2016 at 3:58 PM, Thomas Mäder <span dir="ltr"><<a href="mailto:tmader@redhat.com" target="_blank">tmader@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <p>Hi folks,</p>
    <p>as we move to offer more search functionality in our API, I am
      becoming a bit worried about our architecture in that respect. If
      I look at the search service we have written for the "link
      typeahead" feature, we see code that parses a query string in a
      format that is special to this exact API call, and converts it
      directly into a query on the postgres db. <br>
    </p>
    <p>If we look at what the code does, it could be expressed like
      this:</p>
    <p><code>searchTerms:= parseSpecialSyntax(<wbr>queryString)</code></p>
    <p><code>return select * from work_items i where <a href="http://i.id" target="_blank">i.id</a>
        matches(searchTearms) or i.title matches(searchTerms) or
        i.Description matches(searchTerms)</code></p>
    <p>While the first line is specific to this particular API call, the
      second part can be reused in other queries. I have tried to
      express this separation in the WorkItemRepository.List() method by
      passing in a tree of operators that describes the query instead of
      a query string. <br>
    </p>
    <p>I am quite open to discuss how we want to offer a search API on
      our object model to the request handlers, but I think that we need
      an internal search API layer that offers what we can search for in
      a structure way. Query parsing for special case queries (for
      example, parsing well known URLs) should not be part of this API,
      but done in a layer above. This way we can reuse a lot of checks
      (for example for sql injection) and the translation to the sql
      layer. I believe that we will write a bunch of special case
      queries that we will be able to map to a relatively simple set
      internal search API calls.</p><span class="HOEnZb"><font color="#888888">
    <p>/Thomas<br>
    </p>
  </font></span></div>

<br>______________________________<wbr>_________________<br>
almighty-public mailing list<br>
<a href="mailto:almighty-public@redhat.com">almighty-public@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/almighty-public" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/almighty-<wbr>public</a><br>
<br></blockquote></div><br></div>