[MarkLogic Dev General] how to do query like group and max insql
helen chen
hchen at aip.org
Wed Nov 17 10:07:33 PST 2010
Hi Geert,
Yes, I posted similiar question before, that was for the same coden, and I do a element-values to get volume list, then do element-values to get issue list.
This time it is similiar, but different. I have a list of codens, and I don't need to get list of volumes or list of issues, I only need to get max volume for the coden, and then max issue for the volume/coden. I'm thinking to use cts:element-value-ranges, then I have to do it for each coden and for each volume. if I have 10 codens, then I have to do 20 cts:element-value-ranges. I'm not sure how facet can help me. So I'm wondering if there are any suggestions.
Thanks, Helen
On Nov 17, 2010, at 12:19 PM, Geert Josten wrote:
> Hi Helen,
>
> If your data size is large, distinct-values might get slow. If you add a element value index on coden, then you could use element-values() instead.
>
> Not sure, but your questions looks familiar. Could it be that you posted a similar question before?
>
> Kind regards,
> Geert
>
>>
>
>
> drs. G.P.H. (Geert) Josten
> Consultant
>
> Daidalos BV
> Hoekeindsehof 1-4
> 2665 JZ Bleiswijk
>
> T +31 (0)10 850 1200
> F +31 (0)10 850 1199
>
> mailto:geert.josten at daidalos.nl
> http://www.daidalos.nl/
>
> KvK 27164984
>
>
> De informatie - verzonden in of met dit e-mailbericht - is afkomstig van Daidalos 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.
>
>> From: general-bounces at developer.marklogic.com
>> [mailto:general-bounces at developer.marklogic.com] On Behalf Of
>> Tim Meagher
>> Sent: woensdag 17 november 2010 17:29
>> To: 'General Mark Logic Developer Discussion'
>> Subject: Re: [MarkLogic Dev General] how to do query like
>> group and max insql
>>
>> Oops I left out the order by statement
>>
>>
>>
>> ________________________________
>>
>> From: general-bounces at developer.marklogic.com
>> [mailto:general-bounces at developer.marklogic.com] On Behalf Of
>> Tim Meagher
>> Sent: Wednesday, November 17, 2010 11:26 AM
>> To: 'General Mark Logic Developer Discussion'
>> Subject: Re: [MarkLogic Dev General] how to do query like
>> group and max insql
>>
>>
>>
>> Hi Helen,
>>
>>
>>
>> I guess the first thing I'd want to know is how big the
>> resulting document is going to be and hw you want to store
>> it, i.e. do you want to fragment a large document by coden or
>> perhaps have a separate document for each unique coden.
>>
>>
>>
>> Secondly I would probably approach this as a transform, doing
>> something like this:
>>
>>
>>
>> let $distinct-codens := distinct-values(~/article/coden/text())
>>
>> return
>>
>> for $coden in $distinct-codens
>>
>> order by $coden
>>
>> return element coden {
>>
>> for $article in ~/article
>>
>> where $article/coden/text() eq $coden
>>
>> return (
>>
>> $article/volume,
>>
>> $article/issue,
>>
>> .
>>
>> )
>>
>> }
>>
>>
>>
>> Hope this helps! I hope to see some more robust ideas come out.
>>
>>
>>
>> Tim Meagher
>>
>>
>>
>>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20101117/8a4c24b8/attachment.html
More information about the General
mailing list