I have a list more than ten thousand ids need to retrieve XML data if they are matched. What is a best solution to approach this. I think my code is not the right way to loop through a $listKeyID. Please help. Thanks in advance.
let $listKeyID := ("accid01","accid02",......"accid100000") (: a huge list :)
let $uris := cts:uris((),
(),
cts:and-query((
cts:collection-query("/collection/TRIS"),
cts:or-query((
cts:field-word-query("key",($listKeyID))
))
))
)
)
return fn:count($uris)
Actually, there is not that much wrong with this approach. cts:field-word-query
accepts a sequence as second argument, and will return positive for any match within that sequence. We also refer to that as a shotgun-OR query, and it is pretty efficient.
You don't really need the extra cts:or-query
around it though, and you might want to use a cts:field-value-query
instead, which matches the entire key value, instead of mid-sentence tokens, depending on your use case.
let $listKeyIDs := (accid01,accid02,......accid100000) (: a huge list :)
let $uris := cts:uris(
(),
(),
cts:and-query((
cts:collection-query("/collection/TRIS"),
cts:field-value-query("key", $listKeyIDs)
))
)
return fn:count($uris)
HTH!