Re: [MarkLogic Dev General] how to save multiple documents to file system.

2018-05-10 Thread Damon Feldman
Hi,

I believe you are saving both docs to the file-system with two separate calls. 
I suggest when staring (and even generally) to include the XQuery header:

  declare option xdmp:mapping "false";.

Which will not treat a sequence as an instruction to call a function multiple 
times. That’s what you have now. The comma makes a sequence and then you pass 
that to xdmp:save() which writes *one item* to the file-system. So it loops 
automatically using the “mapping” option and saves twice. Both are saved at the 
same file-name, so you just get one.

But you probably want to save the data into the database. That function is 
xdmp:document-insert($uri, $doc-or-rootNode).l And I suspect you want create a 
new URI in MarkLogic based on the ID or URL attribute.

So try:



xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml;;
let $docs := (
http://dbfeed.ured/EN0001; mimetype="text/html" last-modified="NA" 
pagerank="NA">




,
http://dbfeed.ured/SP0002; mimetype="text/html" last-modified="NA" 
pagerank="NA">





)

for $d in $docs
let $uri := "/" || substring-after($d/@url, "http://;)
return xdmp:document-insert($uri, $d)


From: general-bounces-dev-marklogic  
on behalf of Ly CafeSua 
Reply-To: MarkLogic Discussion 
Date: Thursday, May 10, 2018 at 1:42 PM
To: MarkLogic Discussion 
Subject: [MarkLogic Dev General] how to save multiple documents to file system.

Hello all,

I am new to Marklogic and would like to learn how to save document nodes to 
server.  I have a sample code but it always save a last record has "SP0002".  
How can I save both records.  Thanks in advance.



xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml;;
let $doc := (
 http://dbfeed.ured/EN0001; mimetype="text/html" 
last-modified="NA" pagerank="NA">
 
  
  
 
  ,
  http://dbfeed.ured/SP0002; mimetype="text/html" 
last-modified="NA" pagerank="NA">
  
 
 
   
  
  )

return xdmp:save("/output/mdr/xml/data2016.xml",$doc)
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] how to save multiple documents to file system.

2018-05-10 Thread Ly CafeSua
Hello all,

I am new to Marklogic and would like to learn how to save document nodes to
server.  I have a sample code but it always save a
last record has "SP0002".  How can I save both records.  Thanks in advance.



xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml;;
let $doc := (
 http://dbfeed.ured/EN0001; mimetype="text/html"
last-modified="NA" pagerank="NA">
 
  
  
 
  ,
  http://dbfeed.ured/SP0002; mimetype="text/html"
last-modified="NA" pagerank="NA">
  
 
 
   
  
  )

return xdmp:save("/output/mdr/xml/data2016.xml",$doc)
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] collection function searching

2018-05-10 Thread Erik Hennum
Hi, Paul:

Syntactically, the XPath expressions

*  retrieve a sequence of documents from the database
*  extract a sequence of nodes from the sequence of documents (in case 2)
*  filter to produce a final sequence by applying the predicate to each item

The engine tries to optimize XPath expressions by executing as much as of
the expression as possible as a query against indexes.  Not all expressions are
possible to optimize as a query. The optimizer may also miss some cases that
are possible to optimize.

The best practice is to use explicit queries instead of XPath expressions when
retrieving documents from the database.  That way, the use of indexes is
unambiguous. In addition, you have access to index mechanisms (such as fields)
that aren't available in predicates.

To put it the other way, the best practice is to use XPath expressions only to
traverse nodes after they have been retrieved from the database.

In the particular case, the equivalent query for XPath expression 2 would
resemble the following:

let $ait := cts:search((), cts:and-query((
cts:collection-query($mycol),
cts:element-query(xs:QName("aaa"),
cts:element-value-query(xs:QName("myelem"), "myval"))
)
)))

While the query is more verbose, it declares a carefully considered use of the
indexes.  That's a good thing for scalability and maintainability with most
production databases.

For more information, see:

http://docs.marklogic.com/cts:collection-query
http://docs.marklogic.com/cts:element-query
http://docs.marklogic.com/cts:element-value-query


Hoping that helps,


Erik Hennum




From: general-boun...@developer.marklogic.com 
 on behalf of Paul M 
Sent: Tuesday, May 8, 2018 11:47:35 AM
To: general@developer.marklogic.com
Subject: [MarkLogic Dev General] collection function searching

I have the following three queries I am comparing

declare variable  $my:col as xs:string...
(:
let $ait := collection()[.//myelem="myval"]
:)
(:
let $ait := collection($mycol)/aaa[.//myelem="myval"]
:)

let $ait := collection($mycol)[.//myelem=" myval"]

return $ait//someelem

There may be 10mil total documents in the repository.
There may be 1mil documents that have root element of aaa.
Note:myelem can/should only be in documents  with root element of aaa
There may be 3 mil total documents that are in mycol
There may be at most 100k documents that have root element of aaa which are in 
mycol

The following are the query-trace for the above three statement:
1st one: roughly 3000 fragments to filter. Seems reasonable  aaa documents that 
have myelem = myval
2nd statement: roughly 1000 fragments to filter. Seems reasonable - narrowing 
the search
Last statement: roughly 8 mil fragments to filter. Not certain why this occurs.

Any explanation to shed some light?

___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] unsubscribe

2018-05-10 Thread Philip Fennell

___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] How to specify Collection along with the document URI when inserting a marklogic document

2018-05-10 Thread Bharath Umesh
Thanks Shabana.

That was very helpful.

On Thu, May 10, 2018 at 2:48 PM, shabana khan 
wrote:

> Hi Bharath,
>
> You can add document and collection in single step itself. If you look at
> the syntax of xdmp.documentInsert(), you will seen that you can pass
> collection in options node itself :
>
> declareUpdate();
> xdmp.documentInsert(
>'document URI',
>   document,
>   { collections : 'name of collection'})
>
>
> Thanks and Regards,
> Shabana Khan
> LinkedIn 
>
>
>
>
> On Thu, May 10, 2018 at 12:47 PM, Bharath Umesh 
> wrote:
>
>> Thanks, Christopher.
>>
>> I was able to add document and add this document to its collection in 2
>> steps.
>>
>> declareUpdate();
>> xdmp.documentInsert('> {..}
>> );
>> xdmp:document-add-collections("", "");
>>
>> Is this correct?
>>
>> Thanks,
>> Bharath
>>
>>
>>
>>
>> On Wed, May 9, 2018 at 6:08 PM, Christopher Hamlin 
>> wrote:
>>
>>> The second and third examples at
>>> https://docs.marklogic.com/xdmp:document-insert shows collections
>>> being set.
>>>
>>> Do those work for you?
>>>
>>> On Wed, May 9, 2018 at 7:48 AM, Bharath Umesh 
>>> wrote:
>>> > Hi
>>> >
>>> > How do I specify Collection info  along with the document URI when
>>> inserting
>>> > a marklogic document.
>>> >
>>> >
>>> > Thanks,
>>> > Bharath
>>> >
>>> > ___
>>> > General mailing list
>>> > General@developer.marklogic.com
>>> > Manage your subscription at:
>>> > http://developer.marklogic.com/mailman/listinfo/general
>>> >
>>> ___
>>> General mailing list
>>> General@developer.marklogic.com
>>> Manage your subscription at:
>>> http://developer.marklogic.com/mailman/listinfo/general
>>>
>>
>>
>> ___
>> General mailing list
>> General@developer.marklogic.com
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] How to specify Collection along with the document URI when inserting a marklogic document

2018-05-10 Thread shabana khan
Hi Bharath,

You can add document and collection in single step itself. If you look at
the syntax of xdmp.documentInsert(), you will seen that you can pass
collection in options node itself :

declareUpdate();
xdmp.documentInsert(
   'document URI',
  document,
  { collections : 'name of collection'})


Thanks and Regards,
Shabana Khan
LinkedIn 




On Thu, May 10, 2018 at 12:47 PM, Bharath Umesh  wrote:

> Thanks, Christopher.
>
> I was able to add document and add this document to its collection in 2
> steps.
>
> declareUpdate();
> xdmp.documentInsert(' {..}
> );
> xdmp:document-add-collections("", "");
>
> Is this correct?
>
> Thanks,
> Bharath
>
>
>
>
> On Wed, May 9, 2018 at 6:08 PM, Christopher Hamlin 
> wrote:
>
>> The second and third examples at
>> https://docs.marklogic.com/xdmp:document-insert shows collections
>> being set.
>>
>> Do those work for you?
>>
>> On Wed, May 9, 2018 at 7:48 AM, Bharath Umesh 
>> wrote:
>> > Hi
>> >
>> > How do I specify Collection info  along with the document URI when
>> inserting
>> > a marklogic document.
>> >
>> >
>> > Thanks,
>> > Bharath
>> >
>> > ___
>> > General mailing list
>> > General@developer.marklogic.com
>> > Manage your subscription at:
>> > http://developer.marklogic.com/mailman/listinfo/general
>> >
>> ___
>> General mailing list
>> General@developer.marklogic.com
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>
>
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] How to specify Collection along with the document URI when inserting a marklogic document

2018-05-10 Thread Bharath Umesh
Thanks, Christopher.

I was able to add document and add this document to its collection in 2
steps.

declareUpdate();
xdmp.documentInsert('", "");

Is this correct?

Thanks,
Bharath




On Wed, May 9, 2018 at 6:08 PM, Christopher Hamlin 
wrote:

> The second and third examples at
> https://docs.marklogic.com/xdmp:document-insert shows collections
> being set.
>
> Do those work for you?
>
> On Wed, May 9, 2018 at 7:48 AM, Bharath Umesh  wrote:
> > Hi
> >
> > How do I specify Collection info  along with the document URI when
> inserting
> > a marklogic document.
> >
> >
> > Thanks,
> > Bharath
> >
> > ___
> > General mailing list
> > General@developer.marklogic.com
> > Manage your subscription at:
> > http://developer.marklogic.com/mailman/listinfo/general
> >
> ___
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general