The fn:doc() function call with no arguments will return all documents in the 
database.  So making that the searchable expression in a cts:search() call will 
search the entire database.

You can actually pass multiple uris to fn:doc(), provided that you are using 
either the 0.9-ml or 1.0-ml XQuery dialect.  For example:
    fn:doc(("a.xml", "b.xml"))

I would still prefer to search using a collection or a directory, unless there 
were some specific reason that I wanted to search only a handful of documents.


From: [email protected] 
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Saturday, November 21, 2009 2:00 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] RE: Creating Collections

Thanks.  This is still confusing to me though.
Maybe a simplier question ...
Is there any way to pass 2 distinct doc() expressions to cts:search and have it 
treat them as searchable and return a combined result such that things like 
cts:remainder work.
E.g.  the equivilent of

                cts:search( doc("a.xml") | doc("b.xml") , "term" )

I dont see how I could use your last suggest
                cts:search(fn:doc(), cts:and-query(( 
cts:collection-query("my-collection"), cts:word-query("dog") )))

as the argument to cts:search() is a single document ... but I suspect I'm 
misreading that.

Also I dont mind re-inserting the documents at insert time into collections ... 
I could also insert them into a sub directory so that presumably
                cts:search( cts:directory("/Root/Sub/") , "term" )

would search all docs in that directory as a single searchable result




From: [email protected] 
[mailto:[email protected]] On Behalf Of Mark Helmstetter
Sent: Saturday, November 21, 2009 1:09 PM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] RE: Creating Collections

You don't really explicitly create a collections, generally you will either 
specify the collection(s) for a document when you insert it or you can update 
the document using xdmp:document-add-collections().  Setting them at insert 
time is more ideal, that way you don't incur the extra update to add the 
collections.  You can also assign 1 or more default collections to a particular 
user or role via the Admin interface (Security->Users and Security->Roles).

How you add them at insert time will depend on how you're actually inserting 
your documents.  If you're using xdmp:document-insert() or xdmp:document-load() 
both of those functions have their own way of specifying collections when you 
insert the docs (see the API documentation for details).

As far as using the collections that you create at query time, there are a 
number of options.  One option is to use "cts:search( collection("my 
collection") ... )" as you describe.  This will be a searchable expression, and 
will search all documents within that collection.  You can also use 
cts:collection-query() which can be combined with your other query criteria 
using cts:and-query().  For example:

cts:search(fn:doc(), cts:and-query(( cts:collection-query("my-collection"), 
cts:word-query("dog") )))




From: [email protected] 
[mailto:[email protected]] On Behalf Of Lee, David
Sent: Saturday, November 21, 2009 12:39 PM
To: [email protected]
Subject: [MarkLogic Dev General] Creating Collections

I'm having fun now trying to search 2 documents at once with different 
structures (different root elements among other things)
I know I can put them into a directory and search them via
                cts:search( cts:directory("/dir/") , ...)

but I was trying to see what else I could do, so I tried this
                cts:search( doc("doc1" )/foo/bar | doc("doc2")/spam , ...)

"of course" that didnt work.  (an error about "Not searchable expression").

So what I've done is search twice then combine the results but it causes all 
sorts of unnecessary complexity,

                let $res := cts:search( ... )  | cts:search( ... )

for example the ordering now isn't by score anymore, so I have to add a 
for/order-by to re-order it.
Then the cts:remainder function doesnt work too good
                cts:remainder( $res[1] )
returns the remainder of the first search only.   So then I have to do some 
more fancy stuff to add 2 remainders ...
I bet you can see how this is going .. :)

So I'm looking around for a better way and ran into the collection concept.   
Is that how to solve this ? Create a collection ...
then is the collection searchable ?
                cts:search( collection("my collection") ... )

then the results would be combined right ?

SO ho DO I create a collection ? The only way so far I've found is   
xdmp:documents-add-to-collection()

Is that the only/correct way to create collections ?  Is there something on the 
admin panel that can do it ?

Any pointers to docs that describe collections would be appreciated.  All I 
could find is some very terse references to them but not how to actually create 
and use them.

Thanks for any suggestions !







----------------------------------------
David A. Lee
Senior Principal Software Engineer
Epocrates, Inc.
[email protected]<mailto:[email protected]>
812-482-5224


_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to