David,
Don't forget you can pass a cts:query to cts:contains(). So, you might do:
doc(("1.xml","2.xml"))[cts:contains(.,$query)]
Generally speaking, this is not how you want to search MarkLogic - you don't
want to specify all the documents you want to search by name. For a handful of
documents it is probably fine. Still, I have to ask, why are you trying to
search 2 documents?
Collections are cheap. I would use them generously when inserting or updating
documents. Directories are very useful as well.
Kelly
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