Given this query:
for $d in cts:search(
fn:doc(),
cts:and-query(
(
cts:collection-query(('InProgress_Audit'))
)
))
where not(fn:contains($d//TitleDate/text(),"Z"))
return <p>{document-uri($d)}</p>
How do I move the "where" constraint into the CTS search query?
This uses
cts:query
to apply your constraints:There are index options to speed up wildcarded searches. You could also use a range index on
TitleDate
in combination with acts:element-range-index-query
to speed this up even further.Update: As @mblakele points out in the comments,
cts:element-value-query
may be faster than the nestedcts:element-query
/cts:word-query
:And using cts:uris will be faster than making many repeated calls to
document-uri()
. However, you would need to enable the URI lexicon option in your settings. Putting all that together, the query would look like: