Created
June 17, 2014 15:46
-
-
Save wsalesky/3d419b666225dbc186b4 to your computer and use it in GitHub Desktop.
A simple function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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