[MarkLogic Dev General] General Digest, Vol 129, Issue 61

asit nautiyal nautiyalasit at yahoo.com
Sat Mar 28 02:23:20 PDT 2015


Hi Alex,
use cts:values function to get distinct values which is very fast instead of fn:distinct-values().
Please refer https://docs.marklogic.com/cts:values 
Regards,Asit Nautiyal  


     On Saturday, 28 March 2015 2:27 PM, "general-request at developer.marklogic.com" <general-request at developer.marklogic.com> wrote:
   

 Send General mailing list submissions to
    general at developer.marklogic.com

To subscribe or unsubscribe via the World Wide Web, visit
    http://developer.marklogic.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
    general-request at developer.marklogic.com

You can reach the person managing the list at
    general-owner at developer.marklogic.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of General digest..."


Today's Topics:

  1. Data profiling on large datasets (Alex Jouravlev)
  2. Re: General Digest, Vol 129, Issue 56 (asit nautiyal)


----------------------------------------------------------------------

Message: 1
Date: Sat, 28 Mar 2015 18:05:17 +1100
From: Alex Jouravlev <alexj at businessabstraction.com>
Subject: [MarkLogic Dev General] Data profiling on large datasets
To: MarkLogic Developer Discussion <General at developer.marklogic.com>
Message-ID:
    <CAKAgzBkdOc6NiW+tAg6mzTmBAtKxiWdJ1OJd6V3GR0gSVygPSg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi everybody,

I an trying to list all top-level element types using

> fn:distinct-values(/*[name()])


The database has about 400,000 documents, but only a dozen of top-level
element types
The Query Console returns
[1.0-ml] XDMP-EXPNTREECACHEFULL:
fn:distinct-values(fn:collection()//*[fn:name(.)]) -- Expanded tree cache
full on host hp5

I am running it on a Win8 laptop with 8Gb of RAM and 16Gb of paging space,
with plenty of free disk space. Already expanded tree cash to 8Gb - more
than the data I have.

What am I missing?

Alex Jouravlev
Director, Business Abstraction Pty Ltd
Phone:      +61-(2)-8003-4830
Mobile:    +61-4-0408-3258
Web: http://www.businessabstraction.com
LinkedIn: http://au.linkedin.com/in/alexjouravlev/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20150328/75e473da/attachment-0001.html 

------------------------------

Message: 2
Date: Sat, 28 Mar 2015 08:54:46 +0000 (UTC)
From: asit nautiyal <nautiyalasit at yahoo.com>
Subject: Re: [MarkLogic Dev General] General Digest, Vol 129, Issue 56
To: "general at developer.marklogic.com"
    <general at developer.marklogic.com>,     "PKapoor1 at innodata.com"
    <PKapoor1 at innodata.com>,     "indrajeet.verma at gmail.com"
    <indrajeet.verma at gmail.com>
Message-ID:
    <510923966.150142.1427532886360.JavaMail.yahoo at mail.yahoo.com>
Content-Type: text/plain; charset="utf-8"

Hi Pragya,
Please find the below xquery code and hope it will work fine for you . You can tune it further ?:)
declare function local:get-xml($xml){let $result :=  for $each in $xml/* return if($each/*/text()) ?then  (  ??? ? ? ? ? ? ? ? $each ? ? ? ? ? ? ? ? ? ? ? ? ? ??? ? ? ? ? ? ?)?? ? ? ? ? ? ?else if($each//*/text()) then? ? ? ? ? ? ?(? ? ? ? ? ? ? ?element {fn:local-name($each)} {? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? local:get-xml($each)?? ? ? ? ? ? ? ? ? ? ?}? ? ? ? ? ? ?)  else () return $result };
let $xml := <report>? ? <columns>? ? ? ? <title>Currency</title>? ? </columns>? ? <results>? ? ? ? <result>? ? ? ? ? ? <Currency/>? ? ? ? </result>? ? ? ? <result>? ? ? ? ? ? <Currency/>? ? ? ? </result>? ? ? ? <result>? ? ? ? ? ? <Currency/>? ? ? ? </result>? ? ? ? <result>? ? ? ? ? ? <Currency>Pound sterling</Currency>? ? ? ? </result>? ? ? ? <result>? ? ? ? ? ? <Currency/>? ? ? ? </result>? ? ? ? <result>? ? ? ? ? ? <Currency>Pound sterling</Currency>? ? ? ? </result>? ? </results></report> return ?element {fn:local-name($xml)} { local:get-xml($xml)} 
 



    On Friday, 27 March 2015 6:56 PM, "general-request at developer.marklogic.com" <general-request at developer.marklogic.com> wrote:
  

 Send General mailing list submissions to
??? general at developer.marklogic.com

To subscribe or unsubscribe via the World Wide Web, visit
??? http://developer.marklogic.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
??? general-request at developer.marklogic.com

You can reach the person managing the list at
??? general-owner at developer.marklogic.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of General digest..."


Today's Topics:

? 1. Empty Results (Kapoor, Pragya)
? 2. Re: Empty Results (Dave Cassel)
? 3. Re: Empty Results (Indrajeet Verma)


----------------------------------------------------------------------

Message: 1
Date: Fri, 27 Mar 2015 11:53:09 +0000
From: "Kapoor, Pragya" <PKapoor1 at innodata.com>
Subject: [MarkLogic Dev General] Empty Results
To: MarkLogic Developer Discussion <general at developer.marklogic.com>
Message-ID: <1427457185711.15297 at innodata.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi,


I want to remove the empty result element from the dynamic xml.


For example:

In the below xml, I want to exclude the element(which has no values) The element name are not fixed as this xml is dynamically created.


Exclude the below exlemnt

? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>


dynamic.xml:

<report>
? ? <columns>
? ? ? ? <title>Currency</title>
? ? </columns>
? ? <results>
? ? ? ? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency>Pound sterling</Currency>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency>Pound sterling</Currency>
? ? ? ? </result>
? ? </results>
</report>


Excepted output:

<report>
? ? <columns>
? ? ? ? <title>Currency</title>
? ? </columns>
? ? <results>
?? ? ? ? ? ? <Currency>Pound sterling</Currency>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency>Pound sterling</Currency>
? ? ? ? </result>
? ? </results>
</report>

Thanks
Pragya


"This e-mail and any attachments transmitted with it are for the sole use of the intended recipient(s) and may contain confidential , proprietary or privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this e-mail or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20150327/a89247fa/attachment-0001.html 

------------------------------

Message: 2
Date: Fri, 27 Mar 2015 12:13:04 +0000
From: Dave Cassel <Dave.Cassel at marklogic.com>
Subject: Re: [MarkLogic Dev General] Empty Results
To: MarkLogic Developer Discussion <general at developer.marklogic.com>
Message-ID: <D13AC0E2.ACFA5%dave.cassel at marklogic.com>
Content-Type: text/plain; charset="utf-8"

Pragya, you can do that using XSL or recursive descent in XQuery<http://blog.davidcassel.net/2014/01/recursive-descent-in-xquery/>. The typeswitch case would look something like:

case element() return
? let $children := $node/node() ! local:change(.)
? return
? ? if (fn:exists($children)) then
? ? ? element { fn:node-name($node) } {
? ? ? ? $node/@*,
? ? ? ? $children
? ? ? }
? ? else ()
?

--
Dave Cassel
Developer Community Manager
MarkLogic Corporation<http://www.marklogic.com/>
MarkLogic World - San Francisco April 13 - 17<http://world.marklogic.com/locations/san-francisco/>


From: <Kapoor>, Pragya <PKapoor1 at innodata.com<mailto:PKapoor1 at innodata.com>>
Reply-To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Date: Friday, March 27, 2015 at 7:53 AM
To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Subject: [MarkLogic Dev General] Empty Results


Hi,


I want to remove the empty result element from the dynamic xml.


For example:

In the below xml, I want to exclude the element(which has no values) The element name are not fixed as this xml is dynamically created.


Exclude the below exlemnt

? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>


dynamic.xml:

<report>
? ? <columns>
? ? ? ? <title>Currency</title>
? ? </columns>
? ? <results>
? ? ? ? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency>Pound sterling</Currency>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency/>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency>Pound sterling</Currency>
? ? ? ? </result>
? ? </results>
</report>


Excepted output:

<report>
? ? <columns>
? ? ? ? <title>Currency</title>
? ? </columns>
? ? <results>
?? ? ? ? ? ? <Currency>Pound sterling</Currency>
? ? ? ? </result>
? ? ? ? <result>
? ? ? ? ? ? <Currency>Pound sterling</Currency>
? ? ? ? </result>
? ? </results>
</report>

Thanks
Pragya


"This e-mail and any attachments transmitted with it are for the sole use of the intended recipient(s) and may contain confidential , proprietary or privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this e-mail or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20150327/c82f257a/attachment-0001.html 

------------------------------

Message: 3
Date: Fri, 27 Mar 2015 18:56:13 +0530
From: Indrajeet Verma <indrajeet.verma at gmail.com>
Subject: Re: [MarkLogic Dev General] Empty Results
To: MarkLogic Developer Discussion <general at developer.marklogic.com>
Message-ID:
??? <CAKwHAeiOhSBAd6BXo2Bq841EPwq2KXb8NJs7-NGmmDyj-usWGg at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi Pragya,

If you are using XSLT, please try below code and see if this helps,

 <xsl:template match="@*|node()">
? ? ? ? <xsl:choose>
? ? ? ? ? ? <xsl:when test="descendant-or-self::text()[normalize-space(.)
ne '']">
? ? ? ? ? ? ? ? <xsl:copy>
? ? ? ? ? ? ? ? ? ? <xsl:apply-templates select="@* | node()"/>
? ? ? ? ? ? ? ? </xsl:copy>
? ? ? ? ? ? </xsl:when>
? ? ? ? ? ? <xsl:otherwise/>
? ? ? ? </xsl:choose>
? ? </xsl:template>

Thank you!

On Fri, Mar 27, 2015 at 5:43 PM, Dave Cassel <Dave.Cassel at marklogic.com>
wrote:

>? Pragya, you can do that using XSL or recursive descent in XQuery
> <http://blog.davidcassel.net/2014/01/recursive-descent-in-xquery/>. The
> typeswitch case would look something like:
>
>? case element() return
>? let $children := $node/node() ! local:change(.)
>? return
>? ? if (fn:exists($children)) then
>? ? ? element { fn:node-name($node) } {
>? ? ? ? $node/@*,
>? ? ? ? $children
>? ? ? }
>? ? else ()
> ?
>
>? --
>? Dave Cassel
> Developer Community Manager
> MarkLogic Corporation <http://www.marklogic.com/>
> MarkLogic World - San Francisco April 13 - 17
> <http://world.marklogic.com/locations/san-francisco/>
>
>
>? From: <Kapoor>, Pragya <PKapoor1 at innodata.com>
> Reply-To: MarkLogic Developer Discussion <general at developer.marklogic.com>
> Date: Friday, March 27, 2015 at 7:53 AM
> To: MarkLogic Developer Discussion <general at developer.marklogic.com>
> Subject: [MarkLogic Dev General] Empty Results
>
>? ? Hi,
>
>
>? I want to remove the empty result element from the dynamic xml.
>
>
>? For example:
>
> In the below xml, I want to exclude the element(which has no values) The
> element name are not fixed as this xml is dynamically created.
>
>
>? Exclude the below exlemnt
>? ? <result>
>? ? ? ? ? ? ? <Currency/>
>? ? ? ? ? </result>
>
>? dynamic.xml:
>? <report>
>? ? <columns>
>? ? ? ? <title>Currency</title>
>? ? </columns>
>? ? <results>
>? ? ? ? <result>
>? ? ? ? ? ? <Currency/>
>? ? ? ? </result>
>? ? ? ? <result>
>? ? ? ? ? ? <Currency/>
>? ? ? ? </result>
>? ? ? ? <result>
>? ? ? ? ? ? <Currency/>
>? ? ? ? </result>
>? ? ? ? <result>
>? ? ? ? ? ? <Currency>Pound sterling</Currency>
>? ? ? ? </result>
>? ? ? ? <result>
>? ? ? ? ? ? <Currency/>
>? ? ? ? </result>
>? ? ? ? <result>
>? ? ? ? ? ? <Currency>Pound sterling</Currency>
>? ? ? ? </result>
>? ? </results>
> </report>
>
>
>? Excepted output:
>
>? <report>
>? ? ? <columns>
>? ? ? ? ? <title>Currency</title>
>? ? ? </columns>
>? ? ? <results>
>? ?? ? ? ? ? ? <Currency>Pound sterling</Currency>
>? ? ? ? ? </result>
>? ? ? ? ? <result>
>? ? ? ? ? ? ? <Currency>Pound sterling</Currency>
>? ? ? ? ? </result>
>? ? ? </results>
>? </report>
>
>? Thanks
>? Pragya
>
>
>? "This e-mail and any attachments transmitted with it are for the sole
> use of the intended recipient(s) and may contain confidential , proprietary
> or privileged information. If you are not the intended recipient, please
> contact the sender by reply e-mail and destroy all copies of the original
> message. Any unauthorized review, use, disclosure, dissemination,
> forwarding, printing or copying of this e-mail or any action taken in
> reliance on this e-mail is strictly prohibited and may be unlawful."
>
>
> _______________________________________________
> 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/20150327/d2cffd7c/attachment.html 

------------------------------

_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


End of General Digest, Vol 129, Issue 56
****************************************


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

------------------------------

_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


End of General Digest, Vol 129, Issue 61
****************************************


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


More information about the General mailing list