title: Xquery search on multiple keywords
body: <p>I have written a basic XQuery that takes a parameter, performs a "contains" parameter on the data and returns the relevant data set.</p>
  
  <pre><code>let $search_term:= request:get-parameter("param1",0)
  return 
    &lt;root&gt; { 
      for $node in doc('http://localhost:8080/data/doc.xml')/root/node
        for $value in $node/element/value
          where contains((upper-case($value)), (upper-case($search_term)))
        order by $node/title
        return $node
    } &lt;root&gt;
  </code></pre>
  
  <p>How would I go about extending this to search for multiple parameters. In my Java application, the user enters the search string in an edit box. Therefore the search string may contain many words. Currently, this code only allows for searching on the search string as one entire phrase.</p>
  
  <p>Is it possible to parse all of the words in a "param1" into a string sequence in XQuery and then perform a contains-any-of on this sequence. Finally, in extension, can I then order the results by the number of matches.</p>
  
  <p>Thanks.</p>