Re: [MarkLogic Dev General] Regarding limiting no of co-occurrences returned.

2017-11-28 Thread William Sawyer
Try out the "map" option you can pass to the function.

On Nov 28, 2017 5:54 AM, "shabana khan"  wrote:

> Hi All,
>
> I am using *cts:value-co-occurrences()* for fetching pair of values for
> data set in my project.I have a query too for restricting resultant pair
> only from specific section.
> But the problem I am facing is that duplicate results are being returned
> for each occurrence of values.
> Basically, I am looking for a way by which each pair of value should occur
> only once in result. I looked at the available options and tried using 
> *"limit=N"
> *but that seems to have no effect on this.
> Filtering at later stage is not possible since it slows down the query if
> I go for selecting unique records based on some value.
>
> Is there some way to achieve it. If anyone has faced this problem please
> do share what you did exactly to get unique pair of values.
> Any heads-up will be appreciated.
>
> Thanks and Regards,
> Shabana Khan
> LinkedIn 
>
>
>
>
> ___
> 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 Do Equivalent of While true() Loop In ML?

2017-11-27 Thread William Sawyer
You could recursively spawn or setup a schedule task to run every minute or
faster if needed.

-Will

On Mon, Nov 27, 2017 at 9:56 AM, Eliot Kimber  wrote:

> I have a client-server system where the client is spawning 100s of 1000s
> of jobs on the client. The client polls the servers to see when each
> server’s task queue is ready for more jobs. This all works fine.
>
> Logically this polling is a while-true() loop that will continue until
> either all the servers are offline or all the tasks to be submitted are
> consumed.
>
> In a procedural language this is trivial, but in XQuery 2 I’m not finding
> a way to do it that works. In XQuery 3 I could use the new iterate operator
> but that doesn’t seem to be available in MarkLogic 9.
>
> My first attempt was to use a recursive process, relying on tail recursion
> optimization to avoid blowing the stack buffer. That worked logically but I
> still ran into out-of-memory on the server at some point (around 200K jobs
> submitted) and it seems likely that it was runaway recursion doing it.
>
> So I tried using a simple loop with xdmp:set() to iterate over the tasks
> and use an exception to break out when all the tasks are done:
>
> try {
> for $i in 1 to 100 (: i.e., loop forever :)
> if (empty($tasks))
> then error()
> else submit-task(head($tasks))
> xdmp:set($tasks, tail($tasks))
>  } catch ($e) {
> (: We’re done. (
> }
>
> Is there a better way to do this kind of looping forever?
>
> I’m also having a very strange behavior where in my new looping code I’m
> getting what I think must be a pending commit deadlock that I didn’t get in
> my recursive version of the code. I can trace the code to the xdmp:eval()
> that would commit an update to the task and that code never returns.
>
> Each task is a document that I update to reflect the details of the task’s
> status (start and end times, current processing status, etc.). Those
> updates are all done either in separately-run modules or via xdmp:eval(),
> so as far as I can tell there shouldn’t be any issues with uncommitted
> updates. I didn’t change anything in the logic that updates the task
> documents, only the loop that iterates over the tasks.
>
> Could it be that the use of xdmp:set() to modify the $tasks variable (a
> sequence of  elements) would be causing some kind of commit lock?
>
> Thanks,
>
> Eliot
>
> --
> Eliot Kimber
> http://contrext.com
>
>
>
>
> ___
> 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] What Might Cause Documents to Silently Not Be Created?

2017-11-08 Thread William Sawyer
I agree its hard to say without seeing the code.  When I first switched to
ML 9 I didn't realize the ErrorLog.txt is now broken up by app server like
the access logs and the task server has its own log as well.   So depending
on the error and what app server the thread is executing on it could be in
a different log file.

Other possible things you can check:

   1. Are you hitting the task server max queue size? Should see the error
   in the logs.
   2. Is it possible your code doesn't create unique URIs for each document.
   3. If you are spawning in update mode you may need to manually call
   xdmp:commit()
   4. Possible permission issue? see if an admin user can see all the
   expected documents.

-Will



On Wed, Nov 8, 2017 at 5:09 PM, Markus Flatscher <
flatsch...@avalonconsult.com> wrote:

> It's hard to say without more details about your data and code, but as a
> first guess, did you consider uncatchable exceptions? They can occur at the
> evaluator layer due to query timeouts (e.g., SVC-CANCELED); during the
> commit phase at the data layer, such as when you try to commit a document
> with index configuration violations (e.g., XDMP-RANGEINDEX); and for a
> handful of other reasons. More details: https://help.marklogic.com/
> knowledgebase/article/View/20/16/uncatchable-exceptions
>
> However, with appropriate log levels set, your ErrorLog should still show
> such errors even if the catch block itself can't see and log them.
>
>
> --
> Markus Flatscher
> Senior Consultant, MarkLogic | Avalon Consulting, LLC
> flatsch...@avalonconsult.com
>
> On Wed, Nov 8, 2017 at 5:25 PM, Eliot Kimber  wrote:
>
>> Using ML 9:
>>
>> I have a process that quickly creates a large number of small documents,
>> one for each item in a set of input items.
>>
>> My code is basically:
>>
>> 1. Log that I’m about to act on the input item
>> 2. Act on the input item (send the input item to a remote HTTP end point)
>> 3. Create a new doc reflecting the input item I just acted on
>>
>> This code is within a try/catch and I log the exception, so I should know
>> if there are any exceptions during this process by examining the log.
>>
>> I’m processing about 500K input items, with the processing spread over
>> the 16 threads of my task server. So there are 16 tasks quickly writing
>> these docs concurrently.
>>
>> I know the exact count of the input items and I get that count in the
>> log, so I know that I’m actually processing all the items I should be.
>>
>> However, if I subsequently count the documents created in step 3 I’m
>> short by about 1500, meaning that not all the docs got created, which
>> should not be able to happen unless there was an exception between the log
>> message and the document-insert() call, but I’m not finding any exceptions
>> or other errors reported in the log.
>>
>> My question: is there anything that would cause docs to silently not get
>> created under this kind of heavy-load? I would hope not but just wanted to
>> make sure.
>>
>> I’m assuming this issue is my bug somewhere, but the code is pretty
>> simple and I’m not seeing any obvious way the documents could not get
>> created without a corresponding exception report.
>>
>> Thanks,
>>
>> Eliot
>> --
>> Eliot Kimber
>> http://contrext.com
>>
>>
>>
>>
>> ___
>> 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] Any easy way to set xml version and encoding?

2017-02-02 Thread William Sawyer
It should work if you make it a string literal.

let $rss:= (
  '',
  http://purl.org/dc/elements/1.1/";
xmlns:media="http://search.yahoo.com/mrss/"; xmlns:content="
http://purl.org/rss/1.0/modules/content/"; xmlns:atom="
http://www.w3.org/2005/Atom"; xmlns:sailthru="
http://www.sailthru.com/rss-extension";>

  Some Title
  Some Description
  
  STUFF

  
)

return (
  $rss
)

On Thu, Feb 2, 2017 at 11:47 AM, Christopher Hamlin 
wrote:

> There's some info on controlling serialization here:
> https://help.marklogic.com/knowledgebase/article/View/
> 328/0/xml-serialization-and-output-options
>
> /ch
>
> On Thu, Feb 2, 2017 at 1:45 PM, Kari Cowan  wrote:
>
>> I have a query the returns an RSS output implementation with some custom
>> nodes.
>>
>>
>>
>> I need to insert  ahead of the > version..> declaration.
>>
>>
>>
>> I found this article from 2009 but wanted to check if there was another
>> way or newer simpler approach I could do directly in the xQuery.  Any ideas?
>>
>> http://markmail.org/message/kwu24lbcdrt2dcim
>>
>>
>>
>>
>>
>> let $rss:=
>>
>> http://purl.org/dc/elements/1.1/"; xmlns:media="http://search.yah
>> oo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/";
>> xmlns:atom="http://www.w3.org/2005/Atom"; xmlns:sailthru="http://www.sai
>> lthru.com/rss-extension">
>>
>>   
>>
>> {$title}
>>
>> {$desc}
>>
>> 
>>
>> {$output}
>>
>> 
>>
>>
>>
>> Returns:
>>
>> *[1.0-ml] XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error,
>> unexpected Version_*
>>
>> 67.
>> 68. let $rss:=
>> 69. http://purl.org/dc/elements/1.1/"; xmlns:media="http://search.yah
>> oo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/";
>> xmlns:atom="http://www.w3.org/2005/Atom"; xmlns:sailthru="http://www.sai
>> lthru.com/rss-extension">
>>
>> ___
>> 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] No option to pass query params in xdmp:http-get

2016-10-31 Thread William Sawyer
You need to use the html entity for the ampersand (&) in xquery.  If q1
is also suppose to be a param you need a question mark as well.

http://localhost:8080/?q1=1&q2=2&q3=3

-Will



On Mon, Oct 31, 2016 at 10:01 AM, Shiv Shankar 
wrote:

> Hi,
> I tried calling an external ws with xdmp:http-get() which is deployed in
> local host http://localhost:8080/q1=1&q2=2&q3=3 , it is throwing as
> XDMP-ENTITYREF: (err:XPST0003) Invalid entity reference "q2="
>
> I am trying to call external ws from console. Any advise?
>
> Regards
> Shan.
>
> ___
> 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] wildcard search false positive

2016-10-25 Thread William Sawyer
Found if you create a range index on email then you can use
cts:value-matches to get the matching emails.  If you need the documents
that contain those emails you can use those values in the search.

xdmp:document-insert("1.xml", r...@foo.com),
xdmp:document-insert("2.xml", r...@foo.com.bar
rob@xxxcom);
cts:search(/, cts:element-value-query(xs:QName("email"),
cts:value-match(cts:element-reference(xs:QName("email")),
"*@foo.com"), "exact"), "unfiltered")

-Will

On Tue, Oct 25, 2016 at 11:47 PM, William Sawyer 
wrote:

> On second thought it seems to be a combination of the two that the indexes
> think its a hit.  If you delete either one it matches correctly.
>
> -Will
>
> On Tue, Oct 25, 2016 at 11:32 PM, William Sawyer 
> wrote:
>
>> The second document is a hit because of the first email in the document
>> matches the query.  For example if you remove the first email from the
>> second document then you only get one result.
>>
>> xdmp:document-insert("1.xml", r...@foo.com),
>> xdmp:document-insert("2.xml", rob@xxxcom);
>> cts:search(/doc, cts:element-value-query(xs:QName("email"), "*@foo.com",
>> "wildcarded"), "unfiltered")
>>
>> result:
>> r...@foo.com
>>
>> -Will
>>
>> On Mon, Oct 24, 2016 at 12:36 PM, Whitby, Rob 
>> wrote:
>>
>>> Thanks, I tried on 8.0-6 with no luck.
>>>
>>>
>>>
>>>
>>>
>>> On 24/10/2016, 16:36, "general-boun...@developer.marklogic.com on
>>> behalf of Will Thompson" >> behalf of wthomp...@oconnors.com> wrote:
>>>
>>>
>>>
>>> Hi Rob,
>>>
>>>
>>>
>>> Are you running the most recent update, 8.0-6? There were some
>>> wildcard-related bugfixes in that release, including this one: "40053:
>>> punctuation sensitive wildcarded document matching with
>>> cts:element-value-query might give incorrect results". It's unclear what
>>> exactly that fixes, but it's worth a shot.
>>>
>>>
>>>
>>> -Will
>>>
>>>
>>>
>>>
>>>
>>> > On Oct 24, 2016, at 9:18 AM, Whitby, Rob 
>>> wrote:
>>>
>>> >
>>>
>>> > Hi,
>>>
>>> >
>>>
>>> > I’m having trouble getting a preceding-wildcard search to work
>>> unfiltered. In 2.xml, the presence of the 2nd email ending with "com"
>>> (rob@xxxcom) makes it a match for the search "*@foo.com”.
>>>
>>> >
>>>
>>> > I’ve tried with all the db indexes enabled - is this just not
>>> possible to resolve accurately without filtering?
>>>
>>> >
>>>
>>> > xdmp:document-insert("1.xml", r...@foo.com>> >),
>>>
>>> > xdmp:document-insert("2.xml", r...@foo.com.bar>> mail>rob@xxxcom);
>>>
>>> > cts:search(/, cts:element-value-query(xs:QName("email"), "*@
>>> foo.com", "wildcarded"), "unfiltered")
>>>
>>> >
>>>
>>> >
>>>
>>> >
>>>
>>> > Thanks
>>>
>>> > Rob
>>>
>>> >
>>>
>>> >
>>>
>>> >
>>>
>>> >
>>>
>>> > ___
>>>
>>> > 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] wildcard search false positive

2016-10-25 Thread William Sawyer
On second thought it seems to be a combination of the two that the indexes
think its a hit.  If you delete either one it matches correctly.

-Will

On Tue, Oct 25, 2016 at 11:32 PM, William Sawyer 
wrote:

> The second document is a hit because of the first email in the document
> matches the query.  For example if you remove the first email from the
> second document then you only get one result.
>
> xdmp:document-insert("1.xml", r...@foo.com),
> xdmp:document-insert("2.xml", rob@xxxcom);
> cts:search(/doc, cts:element-value-query(xs:QName("email"), "*@foo.com",
> "wildcarded"), "unfiltered")
>
> result:
> r...@foo.com
>
> -Will
>
> On Mon, Oct 24, 2016 at 12:36 PM, Whitby, Rob 
> wrote:
>
>> Thanks, I tried on 8.0-6 with no luck.
>>
>>
>>
>>
>>
>> On 24/10/2016, 16:36, "general-boun...@developer.marklogic.com on behalf
>> of Will Thompson" > wthomp...@oconnors.com> wrote:
>>
>>
>>
>> Hi Rob,
>>
>>
>>
>> Are you running the most recent update, 8.0-6? There were some
>> wildcard-related bugfixes in that release, including this one: "40053:
>> punctuation sensitive wildcarded document matching with
>> cts:element-value-query might give incorrect results". It's unclear what
>> exactly that fixes, but it's worth a shot.
>>
>>
>>
>> -Will
>>
>>
>>
>>
>>
>> > On Oct 24, 2016, at 9:18 AM, Whitby, Rob 
>> wrote:
>>
>> >
>>
>> > Hi,
>>
>> >
>>
>> > I’m having trouble getting a preceding-wildcard search to work
>> unfiltered. In 2.xml, the presence of the 2nd email ending with "com"
>> (rob@xxxcom) makes it a match for the search "*@foo.com”.
>>
>> >
>>
>> > I’ve tried with all the db indexes enabled - is this just not
>> possible to resolve accurately without filtering?
>>
>> >
>>
>> > xdmp:document-insert("1.xml", r...@foo.com> >),
>>
>> > xdmp:document-insert("2.xml", r...@foo.com.bar> mail>rob@xxxcom);
>>
>> > cts:search(/, cts:element-value-query(xs:QName("email"), "*@foo.com",
>> "wildcarded"), "unfiltered")
>>
>> >
>>
>> >
>>
>> >
>>
>> > Thanks
>>
>> > Rob
>>
>> >
>>
>> >
>>
>> >
>>
>> >
>>
>> > ___
>>
>> > 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] wildcard search false positive

2016-10-25 Thread William Sawyer
The second document is a hit because of the first email in the document
matches the query.  For example if you remove the first email from the
second document then you only get one result.

xdmp:document-insert("1.xml", r...@foo.com),
xdmp:document-insert("2.xml", rob@xxxcom);
cts:search(/doc, cts:element-value-query(xs:QName("email"), "*@foo.com",
"wildcarded"), "unfiltered")

result:
r...@foo.com

-Will

On Mon, Oct 24, 2016 at 12:36 PM, Whitby, Rob 
wrote:

> Thanks, I tried on 8.0-6 with no luck.
>
>
>
>
>
> On 24/10/2016, 16:36, "general-boun...@developer.marklogic.com on behalf
> of Will Thompson"  wthomp...@oconnors.com> wrote:
>
>
>
> Hi Rob,
>
>
>
> Are you running the most recent update, 8.0-6? There were some
> wildcard-related bugfixes in that release, including this one: "40053:
> punctuation sensitive wildcarded document matching with
> cts:element-value-query might give incorrect results". It's unclear what
> exactly that fixes, but it's worth a shot.
>
>
>
> -Will
>
>
>
>
>
> > On Oct 24, 2016, at 9:18 AM, Whitby, Rob 
> wrote:
>
> >
>
> > Hi,
>
> >
>
> > I’m having trouble getting a preceding-wildcard search to work
> unfiltered. In 2.xml, the presence of the 2nd email ending with "com"
> (rob@xxxcom) makes it a match for the search "*@foo.com”.
>
> >
>
> > I’ve tried with all the db indexes enabled - is this just not
> possible to resolve accurately without filtering?
>
> >
>
> > xdmp:document-insert("1.xml", r...@foo.com email>),
>
> > xdmp:document-insert("2.xml", r...@foo.com.bar email>rob@xxxcom);
>
> > cts:search(/, cts:element-value-query(xs:QName("email"), "*@foo.com",
> "wildcarded"), "unfiltered")
>
> >
>
> >
>
> >
>
> > Thanks
>
> > Rob
>
> >
>
> >
>
> >
>
> >
>
> > ___
>
> > 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] What is the best practice for obtaining document content from the results of a search:search query in MarkLogic 7?

2016-05-02 Thread William Sawyer
Have you tried this option? 
On May 2, 2016 4:07 PM, "Tim"  wrote:

> It seems that xdmp:eval() does the trick pretty simply.
>
> Tim
>
> -Original Message-
> From: general-boun...@developer.marklogic.com
> [mailto:general-boun...@developer.marklogic.com] On Behalf Of Tim
> Sent: Sunday, May 01, 2016 5:12 PM
> To: 'MarkLogic Developer Discussion' 
> Subject: [MarkLogic Dev General] What is the best practice for obtaining
> document content from the results of a search:search query in MarkLogic 7?
>
> I see that MarkLogic 8 contains the extract-document-data option, but this
> is not available in MarkLogic 7.  I simply want to extract content from the
> document specified in the path attribute for each match result. What is the
> best practice for doing so?
>
> Thank you!
>
> Tim Meagher
>
>
> ___
> 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


[MarkLogic Dev General] cts:values scoring

2016-01-06 Thread William Sawyer
I have a fact fragment created in the database every time an article is
viewed,  for example:


   12345
   read
   userIdHere
   dateTimeHere


I am wanting to display a distinct list of the most recent viewed
documents.  I found the documentation for cts:values has options for
scoring so I got really excited about using cts:values with a date range
query with linear slope scoring to produce both a distinct list ordered by
most recent.

Example:
cts:values(
cts:element-reference(xs:QName('doc-id'), ("type=string","collation=
http://marklogic.com/collation/";)),
(),
(
  "limit=6",
 "descending",
 "score-logtfidf"
),
cts:and-query((
cts:element-range-query(xs:QName('date'), "<=", fn:current-dateTime(),
("score-function=reciprocal", "slope-factor=2"), 16),
cts:element-range-query(xs:QName('user'), "=", "currentUser", "collation=
http://marklogic.com/collation/";),
cts:element-range-query(xs:QName('type'), '=', "read", "collation=
http://marklogic.com/collation/";)
))
)

The problem is cts:values always returns the values in item order or
frequency order. There is no option to use score order, which makes me ask
the question why can you specify how it scores?  I know there are other
ways to get my desired result.  But it would be a really nice feature to
allow cts:values to return in score order.

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


Re: [MarkLogic Dev General] Constructing JSON objects

2015-03-16 Thread William Sawyer
I had similar desires for a nicer syntax for working with JSON a few months
ago and this is what I came up with.  Its similar to what Micheal was
describing.
https://github.com/williammsawyer/xquerycoder/blob/master/libs/json-functions.xqy

-Will





On Mon, Mar 16, 2015 at 2:03 PM, Will Thompson 
wrote:

> In this case, json:object and json:array are fine - I just wanted nicer
> syntax so that, say, a recursive typeswitch to transform XML to JSON
> wouldn't turn into a mess with all the temp objects. I guess it's also
> probably nice for building arbitrary JSON if there is any nesting involved.
>
> Mike - Right. And best-case scenario, if there is a conflict, I just
> remove the utility functions and everything works :)
>
> -W
>
>
> > On Mar 12, 2015, at 9:36 PM, David Lee  wrote:
> >
> > Making an XQuery function to call the explicit constructor with variable
> key names or number  of keys is not possible directly
> > There isn't the equivalent of map:entry , field names are constant
> expressions and the number of fields is constant, unlike element {}{}
> >
> > You would have to resort to string conversions, in memory node
> operations or evals ...  Or stick with json:object() /json:array()
> > Or write it in Javascript
> >
> > In all cases what would the signature be?   A fundamental mismatch
> between XQuery an JSON is sequences vs arrays there are no vararg functions
> and any construct to nest or bound sequences involves a lot of syntax and
> temporary objects.
> >
> > If you come up with something let us know!
> >
> >
> >
> >
> >
> > Sent from my iPad (excuse the terseness)
> > David A Lee
> > d...@marklogic.com
> >
> >
> >> On Mar 12, 2015, at 9:51 PM, Michael Blakeley 
> wrote:
> >>
> >> I tend to avoid declaring functions or variables in any namespace that
> I know other code is using. But you're doing it with your eyes open, and
> that's probably ok. Someday a server update may conflict. But if that
> happens, I'm sure you'll catch it in testing, and fix it before it breaks
> production.
> >>
> >> Right?
> >>
> >> -- Mike
> >>
> >>> On 12 Mar 2015, at 17:35 , Will Thompson 
> wrote:
> >>>
> >>> Thanks all. The ML8 constructors look very nice.
> >>>
> >>> Mike - That's what I was looking for, thanks. I ended up writing
> something similar using json:array before I saw the reply, but I like your
> implementation better. Also, I appropriated the json: prefix because it
> looked nicer...for example, is there any reason why this would be bad
> (other than ML might decide implement it at some later date)?
> >>>
> >>> declare function json:new(...)
> >>>
> >>> -W
> >>>
>  On Mar 12, 2015, at 4:38 PM, Sudhakar Reddy <
> sudhakar.re...@marklogic.com> wrote:
> 
>  You can also build using JSON node constructors available in ML 8
>  let $json-node := object-node { "id": number-node {12345},
>    "a" : array-node {1,2,3} ,
>    "b" : fn:true(),
>    "c" : number-node {1234},
>    "d" : array-node{
>    number-node {12345},
>    text {"test"},
>    boolean-node {fn:true()},
>    array-node {'aaa','bbb','ccc'}},
>    "e" : object-node { "x": "hello world",
>    "y": fn:false(),
>    "z" : array-node {1, 'a', fn:true()}
>    },
>    "g": null-node {}
>    }
>    return $json-node
> 
>  Thanks
>  Sudhakar
> 
> 
> 
> > On 3/11/15, 6:52 PM, "Erik Hennum" 
> wrote:
> >
> > Hi, Will:
> >
> > You can use json:object() instead of map:map() for a mutable object
> where
> > order is important.
> >
> > I think the API is the same as that of map:map otherwise.
> >
> > JSON nodes, like XML nodes, are immutable.
> >
> > Erik Hennum
> >
> > 
> > From: general-boun...@developer.marklogic.com
> > [general-boun...@developer.marklogic.com] on behalf of Will Thompson
> > [wthomp...@jonesmcclure.com]
> > Sent: Tuesday, March 10, 2015 5:09 PM
> > To: MarkLogic Developer Discussion
> > Subject: [MarkLogic Dev General] Constructing JSON objects
> >
> > Is there a nice way to construct a JSON object similar to how maps
> can be
> > constructed? Typically I would just do it this way:
> >
> > xdmp:to-json(
> > map:new((
> > map:entry('x', 1),
> > map:entry('y', 2)
> > )))
> >
> > Except that order is important in this specific scenario, and this
> ruins
> > ordering.
> >
> > -Will
> > ___
> > General mailing list
> > General@developer.marklogic.com
> > http://developer.marklogic.com/mailman/listinfo/general
> > ___
> 

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

2015-02-19 Thread William Sawyer
Thank you for the quick responses.   After reviewing those approaches and
the not getting the expected results for my use case.  I came up with the
following function. For my use case I needed to ignore days and calculate
the duration based solely from the year and month of each date.

declare function yearMonthDuration($date1 as xs:dateTime, $date2 as
xs:dateTime) {
let $negative := if ( $date1 lt $date2 ) then ( "-" ) else ()
let $year1 := fn:year-from-dateTime($date1)
let $year2 := fn:year-from-dateTime($date2)
let $month1 := fn:month-from-dateTime($date1)
let $month2 := fn:month-from-dateTime($date2)
let $totalMonths := fn:abs( (($year1 - $year2 ) * 12) + ($month1 -
$month2) )
let $years := $totalMonths idiv 12
let $months := $totalMonths mod 12
return (
xs:yearMonthDuration( $negative || "P" || $years || "Y" || $months
|| "M" )
)
};

-Will

On Thu, Feb 19, 2015 at 6:10 PM, Danny Sokolsky <
danny.sokol...@marklogic.com> wrote:

> I'm not sure if this helps, but here is something similar using a
> technique like the functx function does:
>
> http://www.xqueryfunctions.com/xq/functx_yearmonthduration.html
>
>
> 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 :=  xs:duration($date2 - $date1)
> let $years := fn:round(fn:days-from-duration($test) div 365)
> let $months := fn:round((fn:days-from-duration($test) div 365) div 12)
> return
>  ( xs:yearMonthDuration('P1M') * $months +
> xs:yearMonthDuration('P1Y') * $years)
>
> But duration math is strange so I might be doing something wrong.
>
> -Danny
>
>
> -Original Message-
> From: general-boun...@developer.marklogic.com [mailto:
> general-boun...@developer.marklogic.com] On Behalf Of Florent Georges
> Sent: Thursday, February 19, 2015 4:26 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] xs:yearMonthDuration in 1.0-ml
>
>   That function never found its way from the working drafts to the
> recommendation.  You can achieve something similar by using the following
> (yes, by using the average number of days in a month, which is fragile and
> works fine only for large numbers of days, over several
> years):
>
> let $days   := xs:dayTimeDuration("-P3278D") div
> xs:dayTimeDuration('P1D')
> let $months := $days idiv 30.4368499167
> return
>   $months * xs:yearMonthDuration('P1M')
>
>   Regards,
>
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
>
>
> On 20 February 2015 at 01:02, William Sawyer wrote:
> > 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")
> >
> > ___
> > General mailing list
> > General@developer.marklogic.com
> > http://developer.marklogic.com/mailman/listinfo/general
> >
>
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
> ___
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
> ___
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


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

2015-02-19 Thread William Sawyer
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")
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] http://docs.marklogic.com/ Down

2015-02-09 Thread William Sawyer
Anyone know when this will be back up?500 Internal Server ErrorXDMP-FORESTNOT:
Forest RunDMC2-forest not available: XDMP-FORESTERR: Error in merge of
forest RunDMC2-forest: SVC-FILWRT: File write error: write
'/space/MarkLogic/Forests/RunDMC2-forest/0003c276/TreeData': No space left
on device[1.0-ml]Old Errorhttp://marklogic.com/xdmp/error error.xsd" xmlns:error="
http://marklogic.com/xdmp/error"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>
XDMP-FORESTNOT 
1.0-ml Forest
not available XDMP-FORESTNOT: Forest
RunDMC2-forest not available: XDMP-FORESTERR: Error in merge of forest
RunDMC2-forest: SVC-FILWRT: File write error: write
'/space/MarkLogic/Forests/RunDMC2-forest/0003c276/TreeData': No space left
on device false
  RunDMC2-forest
XDMP-FORESTERR merge
RunDMC2-forest
SVC-FILWRT write
/space/MarkLogic/Forests/RunDMC2-forest/0003c276/TreeData
No space left on device 
 
/apidoc/controller/url_rewrite.xqy
1.0-ml 
 
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] Namespaces are getting removed

2014-11-20 Thread William Sawyer
It you want an alternative in memory update library Ryan Dew's has worked
great for me.

https://github.com/ryanjdew/XQuery-XML-Memory-Operations


On Thu, Nov 20, 2014 at 9:57 PM, Michael Blakeley  wrote:

> It can be dangerous to use fn:name in that context. Try fn:node-name
> instead.
>
> The fn:name function returns a string, which can do strange things
> depending on the namespace declarations in context. But fn:node-name
> returns a QName.
>
> Consider this code:
>
> declare namespace t="cat" ;
>
> let $a := 
> return 
> {
>   element { name($a) } { () },
>   element { node-name($a) } { () }
> }
> /*
>
> =>
> 
> 
>
> Using fn:name ends up changing the namespace because the prefix changed.
> Using node-name preserves the original namespace.
>
> Another way to handle this sort of problem is to use the (deprecated)
> namespace axis.
>
> declare namespace t="cat" ;
>
> let $a := 
> return 
> {
>   element { node-name($a) } {
> $a/namespace::* }
> }
> /*
>
> =>
> 
>
> This preserves the declaration for b=goat, even though it was never used.
>
> -- Mike
>
> > On 20 Nov 2014, at 20:48 ,  <
> abhinav.mish...@cognizant.com> wrote:
> >
> > Hi Pragya,
> >
> > Long back ago i also faced similar issue with the in-mem-update library.
> After investigating i found a minor issue in the library.
> >
> >
> > It was due to this code snippet inside _process (..) method.
> >
> > element{ QName(namespace-uri($node), local-name($node)) }{ ...
> >
> >  .
> > }
> >
> > This code snippet is twice (IF and ELSE block ) in the same method.
> Replace the above code snippet with below given code.
> >
> > element{fn:name($node)} {
> > .
> >
> > }
> >
> >
> >
> >
> > Thanks,
> > Abhinav Kumar Mishra
> > From: general-boun...@developer.marklogic.com [
> general-boun...@developer.marklogic.com] on behalf of Kapoor, Pragya [
> pkapo...@innodata.com]
> > Sent: Friday, November 21, 2014 10:04 AM
> > To: MarkLogic Developer Discussion
> > Subject: [MarkLogic Dev General] Namespaces are getting removed
> >
> > Hi,
> >
> > I am using men:node* function to update in-memory xml.
> > The code is removing the namespaces of all elements of the in-memory xml.
> >
> > Code:
> > xquery version "1.0-ml";
> > import module namespace mem = "http://xqdev.com/in-mem-update";
> > at  "/rest-apis/utils/mem.xqy";
> >
> > declare variable $transId := 'test';
> > let $amd :=  xdmp:invoke-function(
> > function() {
> >
>  (fn:doc('/processing/test/amdDocs/test.xml'))
> > } ,
> > 
> >   {xdmp:database("Ingestion")}
> > 
> > )
> > let $doc := fn:doc('/docs/test.xml')
> >   let $elements := $amd//*[@ID]
> >let $doc :=
> >for $element in $elements
> >let $docElements := $doc//*[@ID = $element/@ID]
> > return
> > if($element/@ID = $docElements/@ID) then
> >  (xdmp:set($doc,mem:node-replace($docElements, $element) ),
> >   $doc)
> > else
> >   let $amdParent := $element/..
> >   let $docParent := $doc//*[@Code = $amdParent/@Code]
> >   return
> > (xdmp:set($doc, mem:node-insert-child($docParent, $element)),
> >   $doc)
> > let $validDocs :=  $doc[fn:last()]
> >return $validDocs
> >
> >Data:
> >let $amd :=  xmlns:SE100="SE100" xmlns:CSD100CP="CSD100CP"
> > xmlns:CAR100CP="CAR100CP"
> > xmlns:PET100="PET100"
> > xmlns:IM100CP="IM100CP"
> > xmlns:OP100="OP100"
> > xmlns:OF100PP="OF100PP"
> > xmlns:VAL100CP="VAL100CP"
> > xmlns:MIC100="MIC100"
> > xmlns:CEM100="CEM100"
> > xmlns:TH100CP="TH100CP"
> > xmlns:MRA="MRA"
> > xmlns:ECOLL100PP="ECOLL100PP"
> > xmlns:NAV100CP="NAV100CP"
> > xmlns:AF100="AF100"
> > xmlns:AD100="AD100"
> > xmlns:EOD100-4="EOD100-4"
> > xmlns:AP100="AP100"
> > xmlns:OF100CP="OF100CP"
> > xmlns:THRW100PP="THRW100PP"
> > xmlns:EOD100-3="EOD100-3"
> > xmlns:CEM100PP="CEM100PP"
> > xmlns:TH100="TH100"
> > xmlns:OES100PP="OES100PP"
> > xmlns:MSLA="MSLA"
> > xmlns:ECOLL100CP="ECOLL100CP"
> > xmlns:IME100PP="IME100PP"
> > xmlns:AF100PP="AF100PP"
> > xmlns:AD100PP="AD100PP"
> > xmlns:AT100PP="AT100PP"
> > xmlns:HIC100="HIC100"
> > xmlns:TAX100PP="TAX100PP"
> > xmlns:ROC100="ROC100"
> > xmlns:SUB100PP="SUB100PP"
> > xmlns:THRW100CP="THRW100CP"
> > xmlns:IR101="IR101"
> > xmlns:CEM100CP="CEM100CP"
> > xmlns:SIN100="SIN100"
> > xmlns:OES100CP="OES100CP"
> > xmlns:IME100CP="IME100CP"
> > xmlns:AF100CP="AF100CP"
> > xmlns:AD100CP="AD100CP"
> > xmlns:AT100CP="AT100CP"
> > xmlns:ANX100-1="ANX100-1"
> > xmlns:TAX100CP="TAX100CP"
> > xmlns:ROC100PP="ROC100PP"
> > xmlns:SUB100CP="SUB100CP"
> > xmlns:CTT100="CTT100"
> > xmlns:ATE100="ATE100"
> > xmlns:DD100="DD100"
> > xmlns:CRC100PP="CRC100PP"
> > xmlns:IME100="IME100"
> > xmlns:AL100="AL100"
> > xmlns:PA100="PA100"
> > xmlns:ANX100-3="ANX100-3"
> > xmlns:TAX100="TAX100"
> > xmlns:ROC100CP="ROC100CP"
> > xmlns:CPRE100="CPRE100"
> > xmlns:OCTH100PP="OCTH100PP"
> > xmlns:AET100PP="AET

[MarkLogic Dev General] Limit Active Sessions per user.

2014-07-07 Thread William Sawyer
What is the best way to make it so a user can't be logged in more than once
or twice?  Is there a way to invalidate sessions when a login happens?  I
have tried changing the app server setting "concurrent request limit" with
no success.

Thanks,
-Will
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] XDMP-REVIDXBADQRY: Reverse index bad query: and-query

2014-07-04 Thread William Sawyer
That's what I was thinking as well.  I ended up just removing the cts
namespace and then add it back when evaulating the placeholders.

Thanks,
-Will
On Jul 4, 2014 2:32 PM, "Gavin Haydon" 
wrote:

>  Hi
>
>  I suspect that the fast reverse index is attempting to index all
> serialised cts query elements that are saved into the database. This way it
> can support those fast reverse queries you might want to perform, and find
> the fragments containing the matching cts query.
>
>  Your serialised cts query has been modified to contain placeholders, and
> as such is no longer valid against the schema for cts query, or the
> expectations of the fast index. Could be that you simply cant fast index
> customised cts queries?
>
>  The standard reverse index seems to be more tolerant (and is slower),
> relying heavily upon filtering to remove the false positives. It may not
> run the same checks upon a save.
>
>  Hope this helps.
> Regards
> Gavin Haydon
>
> Sent from my iPad
>
> On 4 Jul 2014, at 20:30, "William Sawyer"  wrote:
>
>   I am trying to save a serialized cts:query with placeholder values into
> a document and it keeps throwing an XDMP-REVIDXBADQRY error.
>
> Example.
> 
> 
> http://marklogic.com/cts";>
> 
> node
> type
> 
> exact
> 
> 
> http://test.com/meta
> ">meta:meta
> id
> 
> exact
> 
> 
> 
> 
>
> I found the document will save if I remove my placeholder elements.  Also
> found if I turn off "fast reverse searches" index then it saves. I want to
> be able to quickly replace any placeholder values and then pass it into
> cts:query().  Is there a way to keep that index on and keep my placeholder
> elements?
>
> ML: 7.0-2.3
>
> Thanks,
>  -Will
>
>  ___
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
>
> This email is from the Press Association. For more information, see
> www.pressassociation.com. This email may contain confidential
> information. Only the addressee is permitted to read, copy, distribute or
> otherwise use this email or any attachments. If you have received it in
> error, please contact the sender immediately. Any opinion expressed in this
> email is personal to the sender and may not reflect the opinion of the
> Press Association. Any email reply to this address may be subject to
> interception or monitoring for operational reasons or for lawful business
> practices.
>
> ___
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
>
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] XDMP-REVIDXBADQRY: Reverse index bad query: and-query

2014-07-04 Thread William Sawyer
I am trying to save a serialized cts:query with placeholder values into a
document and it keeps throwing an XDMP-REVIDXBADQRY error.

Example.


http://marklogic.com/cts";>

node
type

exact


http://test.com/meta
">meta:meta
id

exact





I found the document will save if I remove my placeholder elements.  Also
found if I turn off "fast reverse searches" index then it saves. I want to
be able to quickly replace any placeholder values and then pass it into
cts:query().  Is there a way to keep that index on and keep my placeholder
elements?

ML: 7.0-2.3

Thanks,
-Will
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] XDMP-NOTXN

2014-05-09 Thread William Sawyer
When I set update to false and transaction-mode to query on page it causes
the page to error on everything other request.   Has anyone else seen this
and know how to fix it?

Thanks,
-Will

declare option xdmp:update "false";
declare option xdmp:transaction-mode "query";

500 Internal Server ErrorXDMP-NOTXN: No transaction with identifier
295241064692587278[1.0-ml]

ML: 7.0-2.3
OS: Windows 7
Single Host
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] xdmp:format-number broken?

2014-01-17 Thread William Sawyer
Has anyone been able to to get xdmp:format-number grouping-separator and
group-size parameters to work?

let $value := 12312312
let $picture := "0"
let $language := "en"
let $letter-value := ()
let $ordchar := ()
let $zero-padding := ()
let $grouping-separator := ","
let $grouping-size := 3
return (
  xdmp:format-number($value, $picture, $language, $letter-value, $ordchar,
$zero-padding, $grouping-separator, $grouping-size)
)
 RESULT 
12312312
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general