title: custom constraint with complex logic or alternative
body: <p>Is there any way to create a custom constraint where the right part can include complex logic? i.e.</p>
  
  <pre><code>name:(phil OR tom)
  </code></pre>
  
  <p>In my function, when I get the $right side, the whole value has been reduced to a simple concatenated string of all of the text, i.e.</p>
  
  <pre><code>&lt;cts:word-query xmlns:cts="http://marklogic.com/cts"&gt;
    &lt;cts:text&gt;phil tom&lt;/cts:text&gt;
  &lt;/cts:word-query&gt;
  </code></pre>
  
  <p>What I am looking to do is to take a parsed query and then add my own additions to the parsed query. So I was hoping that there was some way to get the $right parameter to be something like</p>
  
  <pre><code>&lt;cts:or-query xmlns:cts="http://marklogic.com/cts"&gt;
    &lt;cts:word-query&gt;
      &lt;cts:text&gt;phil&lt;/cts:text&gt;
    &lt;/cts:word-query&gt;
    &lt;cts:word-query&gt;
      &lt;cts:text&gt;tom&lt;/cts:text&gt;
    &lt;/cts:word-query&gt;
  &lt;/cts:or-query&gt;
  </code></pre>
  
  <p>I want to take the output results of the query and expand with another query to get the real results. i.e. I have a <code>name</code> constraint which restricts search to various name fields.  After finding the matching people, I want to turn the results into a hierarchy of people from the matching people, maybe 2 levels down.  This does not seem to make sense as a transform result or a custom constraint. Would this just be a custom REST endpoint?  I was hoping to make use of the paging already built into the standard search endpoint.</p>