[MarkLogic Dev General] Forests and Collections querying problem

Darren Govoni darren at ontrenet.com
Sat Aug 9 04:17:39 PDT 2008


Hey Danny,
   Thanks for getting back. I did download cq - its a great tool!
Here's what I got from your query:

Message: XDMP-NOTANODE:
xdmp:describe((collection("MDC"))[1])/child::node() --
"doc("mde:mdc://e09bd84d-f43e-4e8e-b369-03e11633a0fd")" is not
a node

I presume then, my XML document I loaded is not stored as XML. A bit of
a surprise! How do I tell ML to store it as XML? 

Darren

On Fri, 2008-08-08 at 23:19 -0700, Danny Sokolsky wrote:
> Hi Darren,
> 
> Are you sure the document was loaded as XML and not as text or binary?
> 
> try:  xdmp:describe(fn:collection("MDCOL")[1])/node()
> 
> You might also want to get cq from the workshop on the developer site.  It will make it easy to run queries against all of your databases.
> 
> -Danny
> 
> 
> -----Original Message-----
> From: general-bounces at developer.marklogic.com on behalf of Darren Govoni
> Sent: Fri 8/8/2008 12:48 PM
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] Forests and Collections querying problem
>  
> Danny,
>    Thanks again for the tips. I was able to get the query to work.
> 
> ?for $doc in fn:collection(\"MDCOL\") return $doc
> 
> It returns a document in the collection. But when I try to use
> namespaces to retrieve by element, I get nothing.
> 
> declare namespace mde="http://metadata.dod.mil/mdr/ns/MDE/1.0/"
> ?for $doc in fn:collection(\"MDCOL\")/mde:MyElement return $doc
> 
> According to the loaded XML document, this should return a document
> since /MyElement, the root element, is in the mde declared namespace
> (xmlns="?http://metadata.dod.mil/mdr/ns/MDE/1.0/")
> 
> Am I missing something?
> 
> Darren
> 
> On Fri, 2008-08-08 at 11:07 -0700, Danny Sokolsky wrote:
> > Someone else will have to comment on your Java code, as I don't know
> > Java too well, I am afraid (although I don't see where your options
> > variable comes from in your load code--looks like it should be
> > createOptions  ??).
> > 
> > BTW, there are two methods on ContentCreateOptions called setPlaceKeys
> > that you can use to set the forest when creating content.
> > 
> > Also, you might look at RecordLoader in the workshop section of the
> > developer.marklogic.com site (http://developer.marklogic.com/code/).
> > 
> > -Danny
> > 
> > -----Original Message-----
> > From: general-bounces at developer.marklogic.com
> > [mailto:general-bounces at developer.marklogic.com] On Behalf Of Darren
> > Govoni
> > Sent: Friday, August 08, 2008 10:43 AM
> > To: General Mark Logic Developer Discussion
> > Subject: RE: [MarkLogic Dev General] Forests and Collections querying
> > problem
> > 
> > Hi Danny,
> >    Thanks for the rapid response! Well, I'm using XCC and the
> > documentation is rather thin on these details. Here is how I am loading
> > it.
> > 
> > ===========================
> > 
> >             ContentCreateOptions createOptions = new
> > ContentCreateOptions();
> >             String collection = "MDCOL";
> > 
> >             String collections[] = {collection};
> >             createOptions.setCollections(collections);
> >             
> >             Content contents = ContentFactory.newContent(id, xmlStr,
> > options);
> > 
> >             session.insertContent(contents);
> > 
> >             System.out.println("Inserted: " + xmlStr);
> > 
> > I try to read it this way:
> > ===========================
> > 
> > 		RequestOptions options = new RequestOptions();
> >                 
> > 		options.setCacheResult (false);
> > 
> > 		Request request = session.newAdhocQuery ("for $doc in
> > fn:collection(\"MDCOL\") return $doc",options);
> > 		
> > 		ResultSequence rs = session.submitRequest (request);
> > 
> > What is odd to me is there is no way to specify a Forest with XCC (that
> > I can tell) as the XQuery docs describe - for loading it. I saw the
> > content metadata object, but no docs on it I could find.
> > 
> > However, the query is simply enough and the session URI points to the
> > containing MDE database where the forests reside. So I'm stuck!
> > 
> > Darren
> > 
> > On Fri, 2008-08-08 at 10:32 -0700, Danny Sokolsky wrote:
> > > Hi Darren,
> > > 
> > > When you load documents into a database, unless you explicitly state
> > the
> > > forest to which it is loaded (with a forest placement key), the system
> > > will automatically choose a forest for each document during the load
> > > process (this explains why you see "the forests randomly increment
> > their
> > > document count").
> > > 
> > > How did these documents get in the MDCOL collection?  You can do that
> > > upon load or after load with xdmp:document-set-collections.  If the
> > > following query against the MDE database returns 0:
> > > 
> > > xdmp:estimate(fn:collection("MDCOL"))
> > > 
> > > it means there are no documents in that collection named MDCOL.  Your
> > > query seems like it should return all the document in the collection
> > > (although I am not good at java string escaping...).  Maybe there are
> > > actually no documents in that collection?  Maybe the name was
> > > misspelled, either on load or on query?
> > > 
> > > -Danny
> > > 
> > > -----Original Message-----
> > > From: general-bounces at developer.marklogic.com
> > > [mailto:general-bounces at developer.marklogic.com] On Behalf Of Darren
> > > Govoni
> > > Sent: Friday, August 08, 2008 10:04 AM
> > > To: General Mark Logic Developer Discussion
> > > Subject: [MarkLogic Dev General] Forests and Collections querying
> > > problem
> > > 
> > > Hi,
> > >   I want to store a document in a forest and collection. The document
> > is
> > > part of a collection "MDCOL". I currently have 2 forests associated
> > with
> > > my database MDE - they are "MDR" and "MDC". When I connect through XCC
> > > (to the MDE database) and store a document labeled for the "MDC"
> > > collection. I see the forests randomly increment their document count.
> > > Sometimes its the MDR forest, sometimes the MDC. Furthermore, when I
> > > query for all documents in the MDCOL collection, I get none.
> > > 
> > > Request request = session.newAdhocQuery ("for $doc in
> > > fn:collection(\"MDCOL\") return $doc",options);
> > > 
> > > The documentation didn't explain querying collections well enough 
> > > to solve this in short period. Can someone offer a tip?
> > > 
> > > thank you,
> > > Darren
> > > 
> > > 
> > > _______________________________________________
> > > General mailing list
> > > General at developer.marklogic.com
> > > http://xqzone.com/mailman/listinfo/general
> > > _______________________________________________
> > > General mailing list
> > > General at developer.marklogic.com
> > > http://xqzone.com/mailman/listinfo/general
> > 
> > _______________________________________________
> > General mailing list
> > General at developer.marklogic.com
> > http://xqzone.com/mailman/listinfo/general
> > _______________________________________________
> > General mailing list
> > General at developer.marklogic.com
> > http://xqzone.com/mailman/listinfo/general
> 
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
> 
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general



More information about the General mailing list