> Suppose I have a document with a list of elements like > > <item><a>1</a><b>1</b></item> > <item><a>1</a><b>2</b></item> > <item><a>2</a><b>3</b></item> > <item><a>2</a><b>4</b></item> > <item><a>3</a><b>5</b></item> > <item><a>4</a><b>1</b></item> > <item><a>4</a><b>7</b></item> > <item><a>4</a><b>2</b></item> > > To make sense of these, think of them as relation items. > They are saying e.g > a=1 is related both b=1 and b=2 > Another way to look at this data is "property" data > for item a=2 it has 2 properties (3,4) > > My Query is a co-occurrence like query. > I want to find all <a> values where there exists 2 relations (or > properties) of specific values. > > In this case both <a> and <b> refer to elements in a different document > (linked via the <a> value) > > > So I cant use the co-occurrence search in ML (requires the docs to be in > the same fragment). > That leaves me with pure XQuery, where I'm forced to loop over all > values of a > > Something like this. (Havent tried it but its close I think) > > for $a in fn:disinct-values( //item/a/string() ) > let $as := //item[a eq $a] > where exists($as[b eq $value1) and exists($as[b eq $value2]) > return $a > > > The problem is that this is extremely slow when I have 500,000 item > entries. > None of the suggestions solved the basic problem that I cant find > another approach > to do a query which doesnt require a loop over all values of <a> > there is no (to my finding) > cts:search( //item , > magic search that returns matches where a is the same and b > matches both $value1 and $value2 )
how about: let $val1s := //item[b eq $value1] let $val2s := //item[b eq $value2] return $val1s/a[. = $val2s/a] -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/ _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
