for $hit in doc("/db/shakespeare/plays/hamlet.xml")//SPEECH[ft:query(., "nature")]
let $expanded := kwic:expand($hit)
order by ft:score($hit) descending
return
    <div class="speech">{
        for $line in $expanded//LINE[.//exist:match]
        return
            kwic:get-summary($line, ($line/exist:match)[1], <config width="40"/>,
                util:function(xs:QName("local:filter"), 2))
    }</div>