[MarkLogic Dev General] count of element

Geert Josten geert.josten at dayon.nl
Thu May 30 08:15:33 PDT 2013

If you add ‘table’ as fragment root, then this should give an exact count:

xdmp:estimate(cts:search(fn:doc()//table, cts:and-query(())))

But I can imagine that you don’t want to keep table as fragment root

Kind regards,


*Van:* general-bounces at developer.marklogic.com [mailto:
general-bounces at developer.marklogic.com] *Namens *Gary Larsen
*Verzonden:* donderdag 30 mei 2013 17:15
*Aan:* 'MarkLogic Developer Discussion'
*Onderwerp:* Re: [MarkLogic Dev General] count of element

Thanks Clark,

This is returning what appear to be reasonable numbers:


Since I’m using fragments, without the cts:document-fragment-query()  the
counts were small.


*From:* general-bounces at developer.marklogic.com [
mailto:general-bounces at developer.marklogic.com<general-bounces at developer.marklogic.com>]
*On Behalf Of *Clark Richey
*Sent:* Thursday, May 30, 2013 11:03 AM
*To:* MarkLogic Developer Discussion
*Subject:* Re: [MarkLogic Dev General] count of element

What about something like:



Clark D. Richey, Jr.

Technical Director
MarkLogic Corporation

Clark.Richey at marklogic.com

@crichey <https://twitter.com/crichey>
Cell:  +1 240 252 7507

<http://www.marklogic.com/summit-series/washington-dc>*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.**

On May 30, 2013, at 10:33 AM, Gary Larsen <gary.larsen at envisn.com> wrote:

This is probably easy but haven’t figured it out yet.

I’m looking for a query (preferably cts) to return how many times an
element, <table> for example, exists in the database.  The elements would
be located in fragments.



General mailing list
General at developer.marklogic.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20130530/cf09c630/attachment.html 

More information about the General mailing list