Re: [MarkLogic Dev General] The value of @total is not right

2012-05-09 Thread Geert Josten
Hi Sunny, That is a known 'issue'. It is because search results are counted in so-called 'unfiltered' mode for performance reasons. It uses xdmp:estimate under the hood. Apparently you are doing a search that requires filtering of search results. Can you give some more details about your search

Re: [MarkLogic Dev General] The value of @total is not right

2012-05-09 Thread Sunny Wang01
Hi, The below is my one method, the index for search I have added. declare function local:get-search-result($search-condition as xs:string*, $show-me as xs:string* , $start-date as xs:string* ,

Re: [MarkLogic Dev General] The value of @total is not right

2012-05-09 Thread Geert Josten
Hi Sunny, And an example of the search-condition perhaps? On a side track: where do start and end date come from? Kind regards, Geert -Oorspronkelijk bericht- Van: general-boun...@developer.marklogic.com [mailto:general- boun...@developer.marklogic.com] Namens Sunny Wang01

[MarkLogic Dev General] alternative ways to access documents

2012-05-09 Thread Jakob Fix
Hi, So far I've been successfully using document(/content/[type]/[id].xml) to efficiently access a document. This worked because I had both the [type] and the [id] values that make up the path and the filename. Now my scenario has changed and I no longer know the [type] bit of the path. For

Re: [MarkLogic Dev General] alternative ways to access documents

2012-05-09 Thread Michael Blakeley
You are fetching the document twice, aren't you? Try this: collection(metadata)//dt:identifier[. = $id]/root() I don't really like using // but in this case it may be the best option. -- Mike On May 9, 2012, at 13:37, Jakob Fix jakob@gmail.com wrote: Hi, So far I've been

Re: [MarkLogic Dev General] alternative ways to access documents

2012-05-09 Thread Danny Sokolsky
As an alternate, I wonder if you can do this as a URI lexicon query? For example: fn:doc( cts:uri-match(fn:concat(/content/*/, $id, .xml), (), cts:and-query(( cts:collection-query(metadata), cts:element-value-query(xs:QName(dt:identifier), $id) )) ) ) -Danny -Original

Re: [MarkLogic Dev General] alternative ways to access documents

2012-05-09 Thread Jakob Fix
Thanks Mike and Danny, both approaches do work, and they are both fast. Is there any advantage of one over the other? I already have a URI lexicon, so Danny's suggestion doesn't need something that isn't already there, but it's a bit more involved. The trace log seems to indicates that both are

Re: [MarkLogic Dev General] alternative ways to access documents

2012-05-09 Thread Evan Lenz
As yet another alternative, I'd suggest a slight tweak to your original example: Change this: collection(metadata)/*[dt:identifier = $id] To this: collection(metadata)[*/dt:identifier = $id] Don't ask me why the latter is faster, but if you wrap xdmp:plan() around each of the above in

Re: [MarkLogic Dev General] alternative ways to access documents

2012-05-09 Thread Danny Sokolsky
My guess is that, considering you actually want to return the document, that they will be pretty similar in speed. If you did not need to return the document, then I would think the lexicon approach would be faster, as the XPath approach would need to grab the document anyway. -Danny

Re: [MarkLogic Dev General] alternative ways to access documents

2012-05-09 Thread Evan Lenz
Actually, the latter is more natural in your case anyway, since it gives you exactly what you want (without having to call xdmp:node-uri() or doc()). (And it's fast.) Evan On 5/9/12 3:22 PM, Evan Lenz evan.l...@marklogic.com wrote: As yet another alternative, I'd suggest a slight tweak to your

Re: [MarkLogic Dev General] The value of @total is not right

2012-05-09 Thread Sunny Wang01
Hi Geert, The value of parameter is like: $search-condition :Title:*hits* AND sort:ModifiedDate AND modified-date:span $show-me :Course $start-date: 0001-01-01T00:00:00