If there is a range index on coden, then you can substitute the:
fn:distinct-values(//coden)
with
cts:element-values(xs:QName("coden"))
That should speed things up a bit....
-Danny
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Tuesday, April 06, 2010 2:21 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] how to build the tree based on data
How big is your data set ?
The example I gave is pure xquery If the data is large there may not be
much you can do entirely on-demand. Making it go faster in ML may
involve pre-processing the data into a tree structure. I've had to do
the same thing myself from flat struture to generate fast trees.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Helen Chen
Sent: Tuesday, April 06, 2010 4:53 PM
To: General Mark Logic Developer Discussion
Cc: Helen Chen
Subject: Re: [MarkLogic Dev General] how to build the tree based on data
Hi David,
Thanks for the help. I did the list for one coden, this coden is kind
of a little bit big, and it took more than one minute to return the
full list, I added the order by for the for loop.
It is a little too long for real time search result. I need it quicker.
Any suggestions?
Thanks, Helen
On Apr 6, 2010, at 3:45 PM, Lee, David wrote:
> Syntax typo
> Not:
> for $i in $issues := //article[volume eq $v and coden eq $c]
>
> Should be
>
> for $i in //article[volume eq $v and coden eq $c]
>
>
> Probably some others as well
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Lee,
> David
> Sent: Tuesday, April 06, 2010 3:40 PM
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] how to build the tree based on
> data
>
> A very quick pseudocode .... maybe this will give you some ideas.
>
> let $codens := fn:distinct-values( //coden)
> for $c in $codens return
> <coden name="{$c}">
> {
> let $volumes := fn:distinct-values( $c//volume )
> for $v in $volumes
> return
> <volume name="{$v}">
> {
> for $i in $issues := //article[volume eq $v and
> coden eq $c]
> return <issue name="{$i}"/>
> }
> </volume>
> }
> </coden>
>
>
>
>
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Helen
> Chen
> Sent: Tuesday, April 06, 2010 2:29 PM
> To: General Mark Logic Developer Discussion
> Cc: Helen Chen
> Subject: [MarkLogic Dev General] how to build the tree based on data
>
> our data is like in the following structure
> <article>...<coden></coden><volume></volume><issue></issue><paper></
> paper>....</article>
>
> the following are examples of the data, each tag <article> means one
> xml in marklogic:
>
> article 1:
> <article>...<coden>AAA</coden><volume>1</volume><issue>1</
> issue><paper>123</paper>....</article>
> article 2:
> <article>....<coden>AAA</coden><volume>1</volume><issue>2</
> issue><paper>233</paper>....</article>
> article 3:
> <article>....<coden>AAA</coden><volume>2</volume><issue>3</
> issue><paper>355</paper>....</article>
> article 4:
> <article>....<coden>ACD</coden><volume>5</volume><issue>2</
> issue><paper>899</paper>....</article>
> article 5:
> <article>....<coden>ABC</coden><volume>1</volume><issue>3</
> issue><paper>667</paper>....</article>
>
>
> I want to build a tree list based on coden
>
> coden
> volume
> issue
>
>
> so based on the above example data, if I say I want to build the tree
> for coden AAA, I should get:
> AAA
> vol 1
> iss1
> iss 2
> vol 2
> iss 3
>
> Any suggestions on how to build it using marklogic?
>
> Thanks, Helen
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general