Skip to content

Instantly share code, notes, and snippets.

@wsalesky
Created June 17, 2014 15:46
Show Gist options
  • Save wsalesky/3d419b666225dbc186b4 to your computer and use it in GitHub Desktop.
Save wsalesky/3d419b666225dbc186b4 to your computer and use it in GitHub Desktop.
A simple function
xquery version "3.0";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace ft="http://exist-db.org/xquery/lucene";
declare function local:search($terms as xs:string*) as node(){
if(starts-with($terms,'"')) then
<query>
<phrase>{$terms}</phrase>
</query>
else
<query>
<term>{$terms}</term>
</query>
};
let $term := '"et tu"'
let $query := local:search($term)
for $hits in collection('/db/apps/demo-app/data')//tei:sp[ft:query(.,$query)]
return $hits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment