Thanks for the suggestion.
Collections are probably what I want to use, but I'm just experimenting
to try to learn.
In my case I have 2 documents (both large, about 500MB each, with about
20,000 top level elements each) where I want to do a single search
and produce a single set of results ordered by score.
This will lead to a page which shows "Top 10 results" where if you
click on the link it will go to the detail for that record. These
documents are from the same category of data, but are totally different
schemas. They happen right now to reside in a directory with 3 other
documents I do NOT want to search. So my choices are
1) Move these 2 into their own private directory
2) Create a collection with these 2 docs (learning how to do that now,
thanks to the group !)
3) Search the 2 docs seperately and try to combine the results (very
ugly , all sorts of extra work needed to combine the results)
4) Search the 2 documents in ONE search. Thanks to the suggestion of
using multiple documents to fn:doc() I found this search works *exactly
how I want*
The trick here is that I want a particular sub-record returned as the
result, not the entire document, so hence the funky xpath expression
after doc() to pick the 2 kinds of sub record sets I want searched.
cts:search(
fn:doc(("/Mesh/desc2010.xml","/Mesh/supp2010.xml"))/
(DescriptorRecordSet/DescriptorRecord|SupplementalRecordSet/Supplemental
Record),
"Codeine")
This Works !!!!!
And it beats the hell out of my 3 solution which is
cts:search( doc("doc1") ) | cts:search(doc("doc2")) ...
because it seems like now the results are combined which means
remainder() should work on the combined set and I dont have to re-order
the results !
I will definitely look into making a collection and/or separating these
2 docs into their own directory. But good to know I can do this way
too.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Kelly
Stirman
Sent: Saturday, November 21, 2009 3:27 PM
To: [email protected]
Subject: [MarkLogic Dev General] RE: Creating Collections
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
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general