Hi,
I need to get the URIs of a set of documents from the database with the below
pattern:
<doc>
<parent value="p1">
<child value="q1"/>
<child value="q1"/>
<child value="q1"/>
....
</parent>
<parent value="p2">
<child value="q2"/>
<child value="q2"/>
<child value="q3"/>
<child value="q3"/>
....
</parent>
....
</doc>
The documents will have multiple entries of <child/> with the same value
attribute and may appear consecutively.
For this, the below XQURY is written:
fn:distinct-values(for $x in cts:uri-match("(: directory name :)") (: directory
is used to limit the search :)
for $a in doc($x)//parent (:
get the sequence of all parent elements from the document :)
let $b:=$a/child (: get the
sequence of children from the parent :)
for $y in 1 to count($b) (:
iterate over the length of sequence :)
where (for $z in $y+1 to
count($b) (: iterate from the next index to identify a similar child :)
where
($b[$y]/@value=$b[$z]/@value)
return $x) !=
"" (: if any such sequence is found, it won't be empty :)
return $x) (: return the
document URI :)
However, the above XQUERY results into time limit exceed exception if the
directory size is big (and hence searching such documents in the entire
database is not possible).
Please suggest an alternative way to make the search of such documents faster.
N.B. Indexing is done for @value attribute of parent.
Regards,
Nachiketa
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are
not
to copy, disclose, or distribute this e-mail or its contents to any other
person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has
taken
every reasonable precaution to minimize this risk, but is not liable for any
damage
you may sustain as a result of any virus in this e-mail. You should carry out
your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this
e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general