xquery - Moving where into cts:search -
given query:
for $d in cts:search( fn:doc(), cts:and-query( ( cts:collection-query(('inprogress_audit')) ) )) not(fn:contains($d//titledate/text(),"z")) return <p>{document-uri($d)}</p> how move "where" constraint cts search query?
this uses cts:query apply constraints:
for $d in cts:search( fn:doc(), cts:and-not-query( cts:collection-query('inprogress_audit'), cts:element-query(xs:qname('titledate'), cts:word-query('*z*', 'wildcarded')) )) return <p>{document-uri($d)}</p> there index options speed wildcarded searches. use range index on titledate in combination cts:element-range-index-query speed further.
update: @mblakele points out in comments, cts:element-value-query may faster nested cts:element-query/cts:word-query:
cts:element-value-query(xs:qname('titledate'), '*z*', 'wildcarded') and using cts:uris faster making many repeated calls document-uri(). however, need enable uri lexicon option in settings. putting together, query like:
cts:uris((), 'document', cts:and-not-query(( cts:collection-query('inprogress_audit'), cts:element-value-query(xs:qname('titledate'), '*z*', 'wildcarded') ))) ! element p { . }
Comments
Post a Comment