As of ML6 those URI range indexes aren't so hidden anymore. You can use
http://docs.marklogic.com/cts:uri-reference and
http://docs.marklogic.com/cts:collection-reference directly with
http://docs.marklogic.com/cts:value-tuples or
http://docs.marklogic.com/cts:value-co-occurrences in supported code. I'm not
sure how that helps with the directory facet, though.
This might be a case where directory fragments help, despite my usual aversion
to them. I'm thinking about a hybrid approach where you have many matches and
relatively few directories. If you could enumerate the directories you could
test each one with xdmp:exists().
...
for $directory-uri in $list
where xdmp:exists(
cts:search(
collection(),
cts:and-query(
($user-query, cts:directory-query($directory-uri, 'infinity')))))
You could hard-code $list if your directory structure happens to be fixed, but
that isn't likely. If you can tolerate the extra locking from
directory-creation=automatic, or if can you manually create the directories you
use, then this works:
let $list := cts:uris(
(), 'properties',
cts:element-query(xs:QName('prop:directory'), cts:and-query(())))
...
I'd expect that approach to be O(n) with the number of directories, which might
be better than a pure document-uri approach in some situations.
-- Mike
On 17 Jan 2013, at 09:06 , James Fuller <[email protected]> wrote:
> somewhat related ... there are 2 hidden indexes in MarkLogic;
>
> xdmp:document (uris enabled)
>
> xdmp:collection (collection uris enabled)
>
> which you might be able to leverage. The canonical example for these indexes
> are as follows; which returns all uris along with their collection;
>
>
> cts:element-value-co-occurrences(xs:QName("xdmp:collection"),xs:QName("xdmp:document),"map")
>
> as this is hidden, I make no claims on support (as in there is none) ... but
> thought it might be useful
>
> hth, Jim Fuller
>
>
>
> On Thu, Jan 17, 2013 at 3:44 PM, Michael Sokolov <[email protected]> wrote:
> Yeah - thanks Geert and Damon: I think you've confirmed for me that
> there is no directory-faceting as such, but that I can process all the
> matching uris, which was going to be my fallback. My guess is this
> should be acceptable for < 100K matches or so
>
> -Mike
>
> On 1/17/2013 12:37 AM, Damon Feldman wrote:
> > Mike,
> >
> > This is moderately efficient, so may work depending on your use case and
> > the number of matching uris:
> >
> > declare namespace functx = "http://www.functx.com";
> > declare function functx:substring-before-last-fslash($arg as xs:string?)
> > as xs:string? {
> >
> > let $dir := replace($arg, '^(.*)/.*', '$1')
> > return if (ends-with($dir, "/")) then $dir else () (: if there is no /
> > at all, the replace will have no effect, so check the terminating slash to
> > ensure it is a directory :)
> >
> > } ;
> >
> > let $q := ... some query ...
> > distinct-values(cts:uris("", (), $q) !
> > functx:substring-before-last-fslash(.))
> >
> > Note the "!" operator is a shorthand for a for loop in ML 6. Note the
> > function is based on functx, but has the "/" delimiter hard-coded.
> >
> > Yours,
> > Damon
> > --
> > Damon Feldman
> > Sr. Principal Consultant, MarkLogic
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Michael
> > Sokolov
> > Sent: Wednesday, January 16, 2013 10:38 PM
> > To: General Developer Discussion
> > Subject: [MarkLogic Dev General] directory facet?
> >
> > Is there an efficient way to retrieve all the directories containing the
> > documents matching a query, in the way that cts:words does for words?
> >
> > -Mike
> >
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general