jaydip rananavare | 4 Mar 07:19 2015
Picon

[MarkLogic Dev General] Transform response to camel case json

Hi All,

I am trying to convert query response to camel case json.
So I added custom configuration with option camel-case as true but json:transform-to-json-object function returns json without camel case when element name
1. contain '_' (e.g PUBLISH_DATE)
2. is in uppercase it does not convert it to lower case
3. contain '-' (e.g ONE-MORE-ELEMENT) it does not convert first word to lower case (ONEMoreElement)


Here is my query and output 

xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
import module namespace json = "http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";

let $x := xdmp:set-response-content-type("application/json")
let $custom :=
    let $config := json:config("custom")
    let $_ := map:put($config, "camel-case", fn:true())
    return $config

let $xml :=
    <BOOK>
        <AUTHOR>Gambardella, Matthew</AUTHOR>
        <TITLE>XML Developer's Guide</TITLE>
        <GENRE>Computer</GENRE>
        <PRICE>44.95</PRICE>
        <PUBLISH_DATE>2000-10-01</PUBLISH_DATE>
        <DESCRIPTION>An in-depth look at creating applications with XML.</DESCRIPTION>
        <ONE-MORE-ELEMENT>some value</ONE-MORE-ELEMENT>
    </BOOK>

return json:transform-to-json-object($xml, $custom)


output :-

{
    "BOOK": {
        "AUTHOR": "Gambardella, Matthew",
        "TITLE": "XML Developer's Guide",
        "GENRE": "Computer",
        "PRICE": "44.95",
        "PUBLISH_DATE": "2000-10-01",
        "DESCRIPTION": "An in-depth look at creating applications with XML.",
        "ONEMoreElement": "some value"
    }
}


--

Cheers,

Jaydip


<div><div dir="ltr">
<div>Hi All,</div>
<div><br></div>
<div>I am trying to convert query response to camel case json.</div>
<div>So I added custom configuration with option camel-case as true but json:transform-to-json-object function returns json without camel case when element name</div>
<div>1. contain '_' (e.g PUBLISH_DATE)</div>
<div>2. is in uppercase it does not convert it to lower case</div>
<div>3. contain '-' (e.g ONE-MORE-ELEMENT) it does not convert first word to lower case (ONEMoreElement)</div>
<div><br></div>
<div><br></div>
<div>Here is my query and output&nbsp;</div>
<div><br></div>
<div>xquery version "1.0-ml";</div>
<div>declare namespace html = "<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>";</div>
<div>import module namespace json = "<a href="http://marklogic.com/xdmp/json">http://marklogic.com/xdmp/json</a>" at "/MarkLogic/json/json.xqy";</div>
<div><br></div>
<div>let $x := xdmp:set-response-content-type("application/json")</div>
<div>let $custom :=</div>
<div>&nbsp; &nbsp; let $config := json:config("custom")</div>
<div>&nbsp; &nbsp; let $_ := map:put($config, "camel-case", fn:true())</div>
<div>&nbsp; &nbsp; return $config</div>
<div><br></div>
<div>let $xml :=</div>
<div>&nbsp; &nbsp; &lt;BOOK&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;AUTHOR&gt;Gambardella, Matthew&lt;/AUTHOR&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;TITLE&gt;XML Developer's Guide&lt;/TITLE&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;GENRE&gt;Computer&lt;/GENRE&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;PRICE&gt;44.95&lt;/PRICE&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;PUBLISH_DATE&gt;2000-10-01&lt;/PUBLISH_DATE&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;DESCRIPTION&gt;An in-depth look at creating applications with XML.&lt;/DESCRIPTION&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;ONE-MORE-ELEMENT&gt;some value&lt;/ONE-MORE-ELEMENT&gt;</div>
<div>&nbsp; &nbsp; &lt;/BOOK&gt;</div>
<div><br></div>
<div>return json:transform-to-json-object($xml, $custom)</div>
<div><br></div>
<div><br></div>
<div>output :-</div>
<div><br></div>
<div>
<div>{</div>
<div>&nbsp; &nbsp; "BOOK": {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "AUTHOR": "Gambardella, Matthew",</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "TITLE": "XML Developer's Guide",</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "GENRE": "Computer",</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "PRICE": "44.95",</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "PUBLISH_DATE": "2000-10-01",</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "DESCRIPTION": "An in-depth look at creating applications with XML.",</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; "ONEMoreElement": "some value"</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
</div>
<div><br></div>
<div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">
<p><span>Cheers,</span></p>
<p>Jaydip</p>
<p></p>
<p></p>
<p><br></p>
<p></p>
</div></div>
</div></div>
Steiner, David J. (LNG-DAY | 3 Mar 20:56 2015
Picon

[MarkLogic Dev General] cts.search v cts:search

I’m trying to implement a search in javascript.  In xquery, with cts:search you can specify an element to be searched and returned, such as: cts:search(//element.

The javascript cts.search doesn’t seem to have this ability.  Is there a way to affect this in javascript?  I really don’t want the whole doc coming back, just the element.  Yes, the element is a fragment.

Here’s the XQuery I’m trying to replicate in javascript:

for $hit in  cts:search(//word,

    cts:element-word-query(

      xs:QName("word"),

      "tenant for life",

      "exact"))

order by fn:data($hit/../ <at> year)

return

 

XML documents looks like this:

<concepts year="1865">

<word count="8">tenant for life</word>

<word count="5">decree of court</word>

<word count="4">fourth part</word>

</concepts>

 

 

Thanks,
David

 

<div>
<div class="WordSection1">
<div>
<div>
<div>
<div>
<p><span>I&rsquo;m trying to implement a search in javascript.&nbsp; In xquery, with cts:search you can specify an element to be searched and returned, such as: cts:search(//element.<p></p></span></p>
<p><span>The javascript cts.search doesn&rsquo;t seem to have this ability.&nbsp; Is there a way to affect this in javascript?&nbsp; I really don&rsquo;t want the whole doc coming back, just the element.&nbsp; Yes, the element
 is a fragment.<p></p></span></p>
<p><span>Here&rsquo;s the XQuery I&rsquo;m trying to replicate in javascript:<p></p></span></p>
<p><span>for $hit in&nbsp; cts:search(//word,<p></p></span></p>
<p><span>&nbsp;&nbsp;&nbsp; cts:element-word-query(<p></p></span></p>
<p><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xs:QName("word"),<p></p></span></p>
<p><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "tenant for life",<p></p></span></p>
<p><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "exact"))<p></p></span></p>
<p><span>order by fn:data($hit/../ <at> year)<p></p></span></p>
<p><span>return<p></p></span></p>
<p><span><p>&nbsp;</p></span></p>
<p><span>XML documents looks like this:<p></p></span></p>
<p><span>&lt;concepts year="1865"&gt;<p></p></span></p>
<p><span>&lt;word count="8"&gt;tenant for life&lt;/word&gt;<p></p></span></p>
<p><span>&lt;word count="5"&gt;decree of court&lt;/word&gt;<p></p></span></p>
<p><span>&lt;word count="4"&gt;fourth part&lt;/word&gt;<p></p></span></p>
<p><span>&hellip;<p></p></span></p>
<p><span>&lt;/concepts&gt;<p></p></span></p>
<p><span><p>&nbsp;</p></span></p>
<p><span><p>&nbsp;</p></span></p>
<p><span>Thanks,<br>
David<p></p></span></p>
<p><span><p>&nbsp;</p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
Govindan Vijayadamodar | 2 Mar 22:52 2015

[MarkLogic Dev General] Installing MarkLogic in RHEL 7

Hi,
       I installed MarkLogic in RHEL 7 server to test it out.  And got the error  saying libsas.so.2 is missing. I can install cyrus-sasl-lib on RHEL 7, but it will use the libsasl2.so.3 library and not the 0.2 version. So will the libsasl2.so.3 version will suffice? Is it possible to make MarkLogic run in RHEL 7?

--

Thanks,

         Vijay


<div><div dir="ltr">Hi,<div>&nbsp; &nbsp; &nbsp;<span>&nbsp; I installed MarkLogic in RHEL 7 server to test it out.&nbsp; And got the error</span>&nbsp; saying libsas.so.2 is missing. I can install&nbsp;cyrus-sasl-lib on RHEL 7, but it will use the libsasl2.so.3 library and not the 0.2 version. So will the&nbsp;libsasl2.so.3 version will suffice? Is it possible to make MarkLogic run in RHEL 7?</div>
<div><br></div>
<div>-- <br><div class="gmail_signature"><div dir="ltr">
<p><span>Thanks,</span></p>
<p><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Vijay</span></p>
<p><br></p>
</div></div>
</div>
</div></div>
Abhishek.Srivastav | 1 Mar 21:34 2015

[MarkLogic Dev General] MLCP Content Pump#ATTEMPTED_INPUT_COUNT

Hello Folks,

We are using MLCP though custom JAVA solution and trying to capture the total number of record ingested for each file. I was looking MLCP source code and found ContentPumpStats.ATTEMPTED_RECORD_COUNT does the same thing but not sure how to capture inside custom java class invoking ContentPump.runCommand.

Please let me know how to get the count of record inserted using MLCP.


Thanks
Abhishek

<!-- <at> font-face {font-family:Calibri} <at> font-face {font-family:Tahoma} p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif"} a:link, span.MsoHyperlink {color:blue; text-decoration:underline} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline} span.EmailStyle17 {font-family:"Calibri","sans-serif"; color:#1F497D} .MsoChpDefault {font-family:"Calibri","sans-serif"} <at> page WordSection1 {margin:1.0in 1.0in 1.0in 1.0in} -->
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
<div>
<div>
<div>
<div><span>
<div>
<div lang="EN-US">
<div class="WordSection1">
<div>Hello Folks, </div>
<div><br></div>
<div>We are using MLCP though custom JAVA solution and trying to capture the total number of record ingested for each file. I was looking MLCP source code and found ContentPumpStats.ATTEMPTED_RECORD_COUNT does the same thing but not sure
 how to capture inside custom java class invoking ContentPump.runCommand.</div>
<div><br></div>
<div>Please let me know how to get the count of record inserted using MLCP.</div>
<div><br></div>
<div><br></div>
<div>Thanks</div>
<div>Abhishek</div>
<div><br></div>
</div>
</div>
</div>
</span></div>
</div>

&lt;!--
 <at> font-face
	{font-family:Calibri}
 <at> font-face
	{font-family:Tahoma}
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif"}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline}
span.EmailStyle17
	{font-family:"Calibri","sans-serif";
	color:#1F497D}
.MsoChpDefault
	{font-family:"Calibri","sans-serif"}
 <at> page WordSection1
	{margin:1.0in 1.0in 1.0in 1.0in}
--&gt;
</div>
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original
 message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law,
 this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
</div>
Jakob Fix | 28 Feb 22:59 2015
Picon

[MarkLogic Dev General] question about xdmp:encoding-language-detect

Hello,

using ML7.0-3, the above function, given more than 3500 characters of
Latvian news story text, returns Croatian twice and Serbian once in
the top three results:

<encoding-language xmlns="xdmp:encoding-language-detect">
  <encoding>utf-8</encoding>
  <language>hr</language>
  <score>7.081</score>
</encoding-language>
<encoding-language xmlns="xdmp:encoding-language-detect">
  <encoding>utf-8</encoding>
  <language>hr</language>
  <score>7.012</score>
</encoding-language>
<encoding-language xmlns="xdmp:encoding-language-detect">
  <encoding>utf-8</encoding>
  <language>sr</language>
  <score>6.882</score>
</encoding-language>
...

and no Latvian in sight. Google translate as well as
detectlanguage.com correctly and with sufficient self-assurance return
the correct result.

Can someone explain what the reason behind this lack of confidence and
the wrong detection is? Do you need the right language pack (I'm
playing around with the developer licence which I thought is
full-featured)? Is this something that needs training? The doc doesn't
say so.

Thanks!

cheers,
Jakob.
Gary Russo | 24 Feb 23:43 2015
Picon

[MarkLogic Dev General] What are the best practices for securing a Public ROXY REST Extension?

What are the best practices for securing a ROXY REST Extension that is on the public internet?

 

The REST API will use SSL encryption.

 

Are there any rules of thumb to prevent Query, Schema, and JavaScript Injection attacks?

 

Mike has this good post about using external variables. => http://blakeley.com/blogofile/2012/09/28/external-variables-(code-review,-part-ii)/

 

Other NoSQL products, such as Redis, require the ports to be firewalled with a loopback interface to restrict external access. => http://redis.io/topics/security#network-security

 

Is there any value to using the Redis firewall approach?

 

 

 

Gary Russo

Enterprise NoSQL Developer

http://garyrusso.wordpress.com

 

<div><div class="WordSection1">
<p class="MsoNormal">What are the best practices for securing a ROXY REST Extension that is on the public internet?<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">The REST API will use SSL encryption.<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">Are there any rules of thumb to prevent Query, Schema, and JavaScript Injection attacks?<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">Mike has this good post about using external variables. =&gt; <a href="http://blakeley.com/blogofile/2012/09/28/external-variables-(code-review,-part-ii)/">http://blakeley.com/blogofile/2012/09/28/external-variables-(code-review,-part-ii)/</a><p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">Other NoSQL products, such as Redis, require the ports to be firewalled with a loopback interface to restrict external access. =&gt; <a href="http://redis.io/topics/security#network-security">http://redis.io/topics/security#network-security</a><p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">Is there any value to using the Redis firewall approach?<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">Gary Russo<p></p></p>
<p class="MsoNormal">Enterprise NoSQL Developer<p></p></p>
<p class="MsoNormal"><a href="http://garyrusso.wordpress.com/">http://garyrusso.wordpress.com</a><p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
</div></div>
bin ll | 24 Feb 10:33 2015
Picon

[MarkLogic Dev General] Sort-Order query

Hi,

how do i do a sorting on below 3 titles together and return as one sorting result?

<sort-order type="xs:string" collation="http://marklogic.com/collation/codepoint" direction="ascending">
<element ns="" name="CaseTitle"/>
</sort-order>,
<sort-order type="xs:string" collation="http://marklogic.com/collation/codepoint" direction="ascending">
<element ns="" name="Title"/>
</sort-order>,
<sort-order type="xs:string" collation="http://marklogic.com/collation/codepoint" direction="ascending">
<element ns="" name="Title_of_Treaty"/>
</sort-order>

Regards,
Lee
<div><div dir="ltr">Hi,<div><br></div>
<div>how do i do a sorting on below 3 titles together and return as one sorting result?</div>
<div><br></div>
<div>
<div>&lt;sort-order type="xs:string" collation="<a href="http://marklogic.com/collation/codepoint">http://marklogic.com/collation/codepoint</a>" direction="ascending"&gt;</div>
<div>
<span class="">					</span>&lt;element ns="" name="CaseTitle"/&gt;</div>
<div>
<span class="">				</span>&lt;/sort-order&gt;,</div>
<div>
<span class="">				</span>&lt;sort-order type="xs:string" collation="<a href="http://marklogic.com/collation/codepoint">http://marklogic.com/collation/codepoint</a>" direction="ascending"&gt;</div>
<div>
<span class="">					</span>&lt;element ns="" name="Title"/&gt;</div>
<div>
<span class="">				</span>&lt;/sort-order&gt;,</div>
<div>
<span class="">				</span>&lt;sort-order type="xs:string" collation="<a href="http://marklogic.com/collation/codepoint">http://marklogic.com/collation/codepoint</a>" direction="ascending"&gt;</div>
<div>
<span class="">					</span>&lt;element ns="" name="Title_of_Treaty"/&gt;</div>
<div>
<span class="">				</span>&lt;/sort-order&gt;</div>
</div>
<div><br></div>
<div>Regards,</div>
<div>Lee</div>
</div></div>
Maisnam Ns | 23 Feb 06:58 2015
Picon

[MarkLogic Dev General] Error trying to create query options in xml

Hi,

Can someone help me on creating the query options , the first one using

1. QueryOptionsBuilder in Java API works but with xml it is not working, the result I am getting is

1. US 100
2. JP   49
3. ES   23

Basically , I am getting the country and the counts .

QueryOptionsBuilder qob = new QueryOptionsBuilder();

        // expose the "SPEAKER" element range index as "speaker" values
        QueryOptionsHandle options = new QueryOptionsHandle().withValues(
            qob.values("country",
                    qob.range(
                        qob.elementRangeIndex(new QName("country"),
                            qob.stringRangeType(QueryOptions.DEFAULT_COLLATION))),
                    "frequency-order"));


2. QueryOptionsManager optionsMgr = client.newServerConfigManager().newQueryOptionsManager();

        // construct the query options
        String optionXml =
                "<search:options "+
                        "xmlns:search='http://marklogic.com/appservices/search'>"+
                    "<search:constraint name='country'>"+
                        "<search:range collation='http://marklogic.com/collation/' type='xs:string' facet='true'>"+
                        "<search:facet-option>frequency-order</search:facet-option>"+
                        "<search:facet-option>descending</search:facet-option>"+
                        "<search:facet-option>limit=10</search:facet-option>"+
                            "<search:element ns='' name='country'/>"+
                        "</search:range>"+
                    " </search:constraint>"+
                "</search:options>";

        // create a handle to send the query options
        StringHandle writeHandle = new StringHandle(optionXml);
       
        // write the query options to the database
        optionsMgr.writeOptions(OPTIONS_NAME, writeHandle);
        QueryManager queryMgr = client.newQueryManager();
<div><div dir="ltr">
<div>
<div>
<div>
<div>
<div>Hi,<br><br>
</div>Can someone help me on creating the query options , the first one using <br><br>1. QueryOptionsBuilder in Java API works but with xml it is not working, the result I am getting is <br><br>
</div>1. US 100<br>
</div>2. JP&nbsp;&nbsp; 49<br>
</div>3. ES&nbsp;&nbsp; 23<br><br>
</div>Basically , I am getting the country and the counts .<br><div><div><div><div><div>
<br>QueryOptionsBuilder qob = new QueryOptionsBuilder();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // expose the "SPEAKER" element range index as "speaker" values<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; QueryOptionsHandle options = new QueryOptionsHandle().withValues(<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; qob.values("country",<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qob.range(<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qob.elementRangeIndex(new QName("country"),<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qob.stringRangeType(QueryOptions.DEFAULT_COLLATION))),<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "frequency-order"));<br><br><br>2. QueryOptionsManager optionsMgr = client.newServerConfigManager().newQueryOptionsManager();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // construct the query options<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String optionXml =<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "&lt;search:options "+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "xmlns:search='<a href="http://marklogic.com/appservices/search">http://marklogic.com/appservices/search</a>'&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;search:constraint name='country'&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "&lt;search:range collation='<a href="http://marklogic.com/collation/">http://marklogic.com/collation/</a>' type='xs:string' facet='true'&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "&lt;search:facet-option&gt;frequency-order&lt;/search:facet-option&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "&lt;search:facet-option&gt;descending&lt;/search:facet-option&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "&lt;search:facet-option&gt;limit=10&lt;/search:facet-option&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "&lt;search:element ns='' name='country'/&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "&lt;/search:range&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; " &lt;/search:constraint&gt;"+<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;/search:options&gt;";<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // create a handle to send the query options<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; StringHandle writeHandle = new StringHandle(optionXml);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // write the query options to the database<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; optionsMgr.writeOptions(OPTIONS_NAME, writeHandle);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; QueryManager queryMgr = client.newQueryManager();<br>
</div></div></div></div></div>
</div></div>
Joe Bryan | 20 Feb 14:03 2015

Re: [MarkLogic Dev General] cts:element-values on document-properties

Hi Andreas,

You can pass a sequence of URIs to cts:document-query() ( http://docs.marklogic.com/cts:document-query ).

As for your directory query example, maybe you need to set the depth to "infinity"? http://docs.marklogic.com/cts:directory-query

Thanks.

-jb


From: Andreas Hubmer <andreas.hubmer-x8ePVd8JfW3QT0dZR+AlfA@public.gmane.org>
Reply-To: MarkLogic Developer Discussion <general <at> developer.marklogic.com>
Date: Friday, February 20, 2015 at 6:32 AM
To: MarkLogic Developer Discussion <general-ld4jwAGwUXRXKVOp+u0EsQ@public.gmane.orgrklogic.com>
Subject: [MarkLogic Dev General] cts:element-values on document-properties

Hi,

I am wondering whether it is possible to constrain an element-values-query on a property element by a query on the document.

I have a property person and
  cts:element-values(xs:QName("ns:person"))
gives me all values for that property. This works fine.

Now I want to constrain the list of values by a query on the documents to which the properties belong. For example, let's say that I only want the property values of documents within some directory.

let $query := cts:directory-query("/mydir/")
return cts:element-values(xs:QName("ns:person"), (), (), $query))
Now I don't get any results any more. It seems that the result of $query does not contain the properties. Is it possible to do something like cts:properties-fragment-query, but the other way round?

Any ideas?

Thanks,
Andreas
<div>
<div>Hi Andreas,</div>
<div><br></div>
<div>You can pass a sequence of URIs to cts:document-query() (&nbsp;<a href="http://docs.marklogic.com/cts:document-query">http://docs.marklogic.com/cts:document-query</a>&nbsp;).</div>
<div><br></div>
<div>As for your directory query example, maybe you need to set the depth to "infinity"?&nbsp;<a href="http://docs.marklogic.com/cts:directory-query">http://docs.marklogic.com/cts:directory-query</a>
</div>
<div><br></div>
<div>Thanks.</div>
<div><br></div>
<div>-jb</div>
<div><br></div>
<div><br></div>
<span>
<div>
<span>From: </span>Andreas Hubmer &lt;<a href="mailto:andreas.hubmer@...">andreas.hubmer@...</a>&gt;<br><span>Reply-To: </span>MarkLogic Developer Discussion &lt;<a href="mailto:general@...">general <at> developer.marklogic.com</a>&gt;<br><span>Date: </span>Friday, February 20, 2015 at 6:32 AM<br><span>To: </span>MarkLogic Developer Discussion &lt;<a href="mailto:general@...">general@...rklogic.com</a>&gt;<br><span>Subject: </span>[MarkLogic Dev General] cts:element-values on document-properties<br>
</div>
<div><br></div>
<div>
<div>
<div dir="ltr">Hi,
<div><br></div>
<div>I am wondering whether it is possible to constrain an element-values-query on a property element by a query on the document.</div>
<div><br></div>
<div>I have a property person and</div>
<div>&nbsp; cts:element-values(xs:QName("ns:person"))</div>
<div>gives me all values for that property. This works fine.</div>
<div><br></div>
<div>Now I want to constrain the list of values by a query on the documents to which the properties belong. For example, let's say that I only want the property values of documents within some directory.</div>
<div><br></div>
<div>
<div>let $query := cts:directory-query("/mydir/")</div>
<div>return cts:element-values(xs:QName("ns:person"), (), (), $query))</div>
</div>
<div>Now I don't get any results any more. It seems that the result of $query does not contain the properties. Is it possible to do something like&nbsp;cts:properties-fragment-query, but the other way round?</div>
<div><br></div>
<div>Any ideas?</div>
<div><br></div>
<div>Thanks,</div>
<div>Andreas</div>
</div>
</div>
</div>
</span>
</div>
Andreas Hubmer | 20 Feb 12:32 2015

[MarkLogic Dev General] cts:element-values on document-properties

Hi,

I am wondering whether it is possible to constrain an element-values-query on a property element by a query on the document.

I have a property person and
  cts:element-values(xs:QName("ns:person"))
gives me all values for that property. This works fine.

Now I want to constrain the list of values by a query on the documents to which the properties belong. For example, let's say that I only want the property values of documents within some directory.

let $query := cts:directory-query("/mydir/")
return cts:element-values(xs:QName("ns:person"), (), (), $query))
Now I don't get any results any more. It seems that the result of $query does not contain the properties. Is it possible to do something like cts:properties-fragment-query, but the other way round?

Any ideas?

Thanks,
Andreas
<div><div dir="ltr">Hi,
<div><br></div>
<div>I am wondering whether it is possible to constrain an element-values-query on a property element by a query on the document.</div>
<div><br></div>
<div>I have a property person and</div>
<div>&nbsp; cts:element-values(xs:QName("ns:person"))</div>
<div>gives me all values for that property. This works fine.</div>
<div><br></div>
<div>Now I want to constrain the list of values by a query on the documents to which the properties belong. For example, let's say that I only want the property values of documents within some directory.</div>
<div><br></div>
<div>
<div>let $query := cts:directory-query("/mydir/")</div>
<div>return cts:element-values(xs:QName("ns:person"), (), (), $query))</div>
</div>
<div>Now I don't get any results any more. It seems that the result of $query does not contain the properties. Is it possible to do something like&nbsp;cts:properties-fragment-query, but the other way round?</div>
<div><br></div>
<div>Any ideas?</div>
<div><br></div>
<div>Thanks,</div>
<div>Andreas</div>
</div></div>
William Sawyer | 20 Feb 01:02 2015
Picon

[MarkLogic Dev General] xs:yearMonthDuration in 1.0-ml

I have two dates I am trying to subtract and get a xs:yearMonthDuration.  In "0.9-ml" there is a function you can call but in "1.0-ml" the documentation says to subtract the dates.  But how do I specify that I want a  xs:yearMonthDuration instead of a xs:dayTimeDuration.
MarkLogic Version: 7.0-2.3

Thanks,
-Will


xquery version "1.0-ml";

let $date1 := xs:dateTime(xs:date("2015-03-27"))
let $date2 := xs:dateTime(xs:date("2024-03-27"))
let $test := $date1 - $date2
return $test
***************
xs:dayTimeDuration("-P3288D")


xquery version "0.9-ml"

let $date1 := xs:dateTime(xs:date("2015-03-27"))
let $date2 := xs:dateTime(xs:date("2024-03-27"))
let $test := fn:subtract-dateTimes-yielding-yearMonthDuration($date1, $date2)
return $test
**************
xs:yearMonthDuration("-P8Y11M")
<div><div dir="ltr">I have two dates I am trying to subtract and get a xs:yearMonthDuration.&nbsp; In "0.9-ml" there is a function you can call but in "1.0-ml" the documentation says to subtract the dates.&nbsp; But how do I specify that I want a &nbsp;xs:yearMonthDuration instead of a&nbsp;<span>xs:dayTimeDuration.  
</span><br>MarkLogic Version:&nbsp;7.0-2.3<div><br></div>
<div>Thanks,</div>
<div>-Will</div>
<div>
<br><div><br></div>
<div>
<div>xquery version "1.0-ml";</div>
<div><br></div>
<div>let $date1 := xs:dateTime(xs:date("2015-03-27"))</div>
<div>let $date2 := xs:dateTime(xs:date("2024-03-27"))</div>
<div>let $test := $date1 - $date2</div>
<div>return $test<br>***************<br><span>xs:dayTimeDuration("-P3288D")</span><br>
</div>
</div>
<div><br></div>
<div><br></div>
<div>
<div>xquery version "0.9-ml"</div>
<div><br></div>
<div>let $date1 := xs:dateTime(xs:date("2015-03-27"))</div>
<div>let $date2 := xs:dateTime(xs:date("2024-03-27"))</div>
<div>let $test := fn:subtract-dateTimes-yielding-yearMonthDuration($date1, $date2)</div>
<div>return $test</div>
</div>
<div>**************≤br><span>xs:yearMonthDuration("-P8Y11M")</span><br>
</div>
</div>
</div></div>

Gmane