[MarkLogic Dev General] xdmp:estimate() and fn:distinct-values()

David Lee David.Lee at marklogic.com
Sat Aug 4 03:28:54 PDT 2012


Untested Suggestion.
Put userId into a element range index then use   estimate (cts:values())


-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
dlee at marklogic.com
Phone: +1 650-287-2531
Cell:  +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>

This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation.

From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Danny Sinang
Sent: Friday, August 03, 2012 10:38 PM
To: general
Subject: [MarkLogic Dev General] xdmp:estimate() and fn:distinct-values()

Hello,

The query below runs quite fast (i.e. below 1 second).

let $totalCount := xdmp:estimate(/user[reg/productId=$myBooks]/userId)
let $numUnexpired := xdmp:estimate(/user[reg[productId=$myBooks and (endDate = 0 or endDate >= $current-epoch-time)]]/userId)
return ($totalCount, $numUnexpired, xdmp:elapsed-time())

Problem is, what I really need is to get the number of distinct values of "userId".

Doing xdmp:estimate(fn:distinct-values()) results in in XDMP:UNSEARCHABLE error.

Using fn:count() instead of xdmp:estimate() works, but takes so long (i.e. 30 seconds).

Is there a workaround for this ?

Regards,
Danny


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20120804/debed8c5/attachment.html 


More information about the General mailing list