<pre class="brush:xquery">
(: 1st example :)
//*[text() = 'Germany'],
(: 2nd example :)
doc('factbook.xml')//name[. = 'Germany'],
(: 3rd st example :)
for $c in db:open('factbook')//country
where $c//city/name = 'Hanoi'
</pre>
Since {{Version|7.2.1}}), the text index also supports range queries based on string comparisons:
<pre class="brush:xquery">
(: 1st example :)
db:open('Library')//Medium[Year >= '2005' and Year <= '2007'],
(: 2nd example :)
let $min := '2011-04-16T00:00:00'
let $max := '2011-04-19T23:59:59'
==Attribute Index==
Similar to the text index, this index speeds up string-based range and equality tests on attribute values. The [[Options#UPDINDEX|UPDINDEX]] option can be activated to keep this index up-to-date.
The following queries will all be rewritten for index access:
<pre class="brush:xquery">
(: 1st example :)
//country[@car_code = 'J'],
(: 2nd example :)
//province[@* = 'Hokkaido']//name,
(: 3rd example :)//sea[@depth >= '2100' and @depth <= '4000']
</pre>
<pre class="brush:xquery">
(: 1st example :)
//country/name[text() contains text 'and'],
(: 2nd example :)
//religions[. contains text { 'Catholic', 'Roman' }
using case insensitive distance at most 2 words]