[MarkLogic Dev General] Cts query for element attribute value matching another attribute value?
Danny Sokolsky
Danny.Sokolsky at marklogic.com
Sun Feb 12 10:15:21 PST 2012
Hi Geert,
If you have range indexes on elem/@att1 and elem/@att2, you might be able to do some clever things. For example, you could quickly find the values that the 2 attributes share, then do a much more targeted search with those specific values. You also might be able to do something similar with cts:element-attribute-range-queries or with co-occurrences, although I cannot picture what the code might look like to do that.
For the first thing, the idea is to get all the same values and iterate over them creating and-queries for each value, something like (I have not run this, so it likely has syntax and/or logic errors):
let $samevalues := cts:element-attribute-values(xs:QName("elem"), xs:QName("att1")) = cts:element-attribute-values(xs:QName("elem"), xs:QName("att2"))
return //elem[cts:contains(., cts:or-query((
for $x in $samevalues return
cts:and-query(( cts:element-attribute-value-query(xs:QName("elem"), xs:QName("att1"), $x),
cts:element-attribute-value-query(xs:QName("elem"), xs:QName("att1"), $x) )) )) )]
-Danny
________________________________________
From: general-bounces at developer.marklogic.com [general-bounces at developer.marklogic.com] On Behalf Of Geert Josten [geert.josten at dayon.nl]
Sent: Sunday, February 12, 2012 1:16 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Cts query for element attribute value matching another attribute value?
I am trying to isolate some specific element with two attributes who's
values are equal. I know I can use an expression like doc()//elem[@att1 =
@att2], which is even fully searchable according to xdmp:plan, but I'd
prefer a cts:query, which I could pass into cts:element-attribute-values.
I need unique values, and I am trying to prevent using distinct-values on
the above XPath expression..
Any suggestions?
Kind regards,
Geert
drs. G.P.H. (Geert) Josten
Senior Developer
Dayon B.V.
Delftechpark 37b
2628 XJ Delft
T +31 (0)88 26 82 570
geert.josten at dayon.nl
www.dayon.nl
De informatie - verzonden in of met dit e-mailbericht - is afkomstig van
Dayon BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan
dit bericht kunnen geen rechten worden ontleend.
_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general
More information about the General
mailing list