Simple expressions using the full-text index

Find out where Juliet talks about love

In the following, Jon Bosak's edition of the Shakespeare's Hamlet, Macbeth, and Romeo and Juilet are queried..

    collection("@@path/data")//SPEECH[ft:query(., 'love')][SPEAKER = "JULIET"]
            

Search for a phrase

    collection("@@path/data")//SPEECH[ft:query(., '"fenny snake"')]

Find speeches in which "love" and "father" occur closely together, using XML query syntax:

let $query :=
    <query>
        <near slop="20"><term>love</term><near>father</near></near>
    </query>
return collection("@@path/data")//SPEECH[ft:query(., $query)]
            

Find speeches in which "boil" and "bubble" occur, ordering them by full-text match score

for $m in collection("@@path/data")//SPEECH[ft:query(., "boil bubble")]
let $score := ft:score($m)
order by $score descending
return <m score="{$score}">{$m}</m>