You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by Jayaram Narayana <na...@india.hp.com> on 2002/03/25 10:32:17 UTC

Document-level Queries

guys,

i am wondering how to use the xindice api to query a collection at the
*document* level. i am not able to figure this out by reading the api. could
anyone help me here please?

many thanks,
-nani


Re: Document-level Queries

Posted by "Mark J. Stang" <ma...@earthlink.net>.
If the root of the document is unique, then you can search the whole collection
using an xpath query with "/documenttag".   This will bring back all of them that
match.   If you know an attribute of the root tag, then you can search on that
also.   If you know the key, you can do a direct read using getResource("key").

HTH,

Mark

Mike Gratton wrote:

> Jayaram Narayana wrote:
> >
> > i am wondering how to use the xindice api to query a collection at the
> > *document* level. i am not able to figure this out by reading the api. could
> > anyone help me here please?
> >
>
> Using XPathQueryService.queryResource(String id, String query), where
> 'id' is the id of the document you want to query.
>
> HTH.
> Mike.
>
> --
> Mike Gratton <mi...@vee.net>, <http://web.vee.net/>
> "Every motive escalate."


Re: Document-level Queries

Posted by Mike Gratton <mi...@vee.net>.

Jayaram Narayana wrote:
> 
> i am wondering how to use the xindice api to query a collection at the
> *document* level. i am not able to figure this out by reading the api. could
> anyone help me here please?
> 

Using XPathQueryService.queryResource(String id, String query), where 
'id' is the id of the document you want to query.

HTH.
Mike.

-- 
Mike Gratton <mi...@vee.net>, <http://web.vee.net/>
"Every motive escalate."


RE: Document-level Queries

Posted by Jayaram Narayana <na...@india.hp.com>.
me in bangalore, india.

hey, the only place in the documentation on the topic of indexing is in the
command line reference. is there any more detail to this topic? example,
more theory, how and when *exactly* do you use indexing, how it improves
performance, etc?

are you following the cricket against the proteas?

cheers,
-nani

-----Original Message-----
From: Michael Gratton [mailto:mike@vee.net]
Sent: Tuesday, March 26, 2002 9:51 AM
To: xindice-dev@xml.apache.org
Subject: Re: Document-level Queries




Jayaram Narayana wrote:
> SDH (Sure Did Help!!!!)  ;-)
>

Cool. 8)

> should have been
>
> // query a resource called: ad
> ResourceSet resultSet = service.queryResource("ad", xpath);

Yep, you're right. That's the problem with cutting and pasting..

> hey, in which part of this planet do you exist?
>

In Adelaide, Australia. What about you?

--
Mike Gratton <mi...@vee.net>, <http://web.vee.net/>
Leader in leachate production and transmission since 1976.



Re: Document-level Queries

Posted by Michael Gratton <mi...@vee.net>.

Jayaram Narayana wrote:
> SDH (Sure Did Help!!!!)  ;-)
> 

Cool. 8)

> should have been
> 
> // query a resource called: ad
> ResourceSet resultSet = service.queryResource("ad", xpath);

Yep, you're right. That's the problem with cutting and pasting..

> hey, in which part of this planet do you exist?
> 

In Adelaide, Australia. What about you?

-- 
Mike Gratton <mi...@vee.net>, <http://web.vee.net/>
Leader in leachate production and transmission since 1976.


RE: Document-level Queries

Posted by Jayaram Narayana <na...@india.hp.com>.
SDH (Sure Did Help!!!!)  ;-)

however,

// query a resource called: ad
ResourceSet resultSet = service.query("ad", xpath);

should have been

// query a resource called: ad
ResourceSet resultSet = service.queryResource("ad", xpath);

thanks michael! hey, in which part of this planet do you exist?

sincerely,
-nani

-----Original Message-----
From: Michael Gratton [mailto:mike@vee.net]
Sent: Tuesday, March 26, 2002 9:25 AM
To: xindice-dev@xml.apache.org
Subject: Re: Document-level Queries




Jayaram Narayana wrote:
> thanks michael for your answer. unfortunately, i already knew this as read
> from the documentation. it is not helping me query a document in the
> following simple hierarchy:
>

Right, well, to use your example, and to borrow from the Xindice
developer's guide, here's an example code fragment:

// get your collection: /db/a
Collection col = DatabaseManager.getCollection("xmldb:xindice:///db/a");

// set up the query
String xpath = "//project";
XPathQueryService service =
   (XPathQueryService) col.getService("XPathQueryService", "1.0");

// query a resource called: ad
ResourceSet resultSet = service.query("ad", xpath);

// do something with the results

>
> is there a good 'chart' somewhere of the xindice api contents and
hierarchy?
>

Well, you don't need to deal with the Xindice API, you only really need
to deal with the XMLDB api. I find the Javadocs best for this sort of
thing..

> btw, what is HTH?
>

An appreviation for "Hope That Helps".. 8)

--
Mike Gratton <mi...@vee.net>, <http://web.vee.net/>
Leader in leachate production and transmission since 1976.



Re: Document-level Queries

Posted by Michael Gratton <mi...@vee.net>.

Jayaram Narayana wrote:
> thanks michael for your answer. unfortunately, i already knew this as read
> from the documentation. it is not helping me query a document in the
> following simple hierarchy:
> 

Right, well, to use your example, and to borrow from the Xindice 
developer's guide, here's an example code fragment:

// get your collection: /db/a
Collection col = DatabaseManager.getCollection("xmldb:xindice:///db/a");

// set up the query
String xpath = "//project";
XPathQueryService service =
   (XPathQueryService) col.getService("XPathQueryService", "1.0");

// query a resource called: ad
ResourceSet resultSet = service.query("ad", xpath);

// do something with the results

> 
> is there a good 'chart' somewhere of the xindice api contents and hierarchy?
> 

Well, you don't need to deal with the Xindice API, you only really need 
to deal with the XMLDB api. I find the Javadocs best for this sort of 
thing..

> btw, what is HTH?
> 

An appreviation for "Hope That Helps".. 8)

-- 
Mike Gratton <mi...@vee.net>, <http://web.vee.net/>
Leader in leachate production and transmission since 1976.


RE: Document-level Queries

Posted by Jayaram Narayana <na...@india.hp.com>.
thanks michael for your answer. unfortunately, i already knew this as read
from the documentation. it is not helping me query a document in the
following simple hierarchy:

/db/a/ad - where 'ad' is one of many documents in the collection 'a'. i am
able to getResource("ad") and do a getContent() on the resulting resource.
what i am unable to do is query the resource 'ad' with xpath expressions
like "//project" etc. i am not able to figure out what classes and methods
to achieve this. i sure hope you got and appreciate my issue here. i am
eagerly awaiting your answer.

is there a good 'chart' somewhere of the xindice api contents and hierarchy?

btw, what is HTH?

thanks in advance for any enlightenment :-)
-nani

-----Original Message-----
From: Jayaram Narayana [mailto:nani@india.hp.com]
Sent: Monday, March 25, 2002 3:02 PM
To: 'Xindice Dev. Group'
Subject: Document-level Queries


guys,

i am wondering how to use the xindice api to query a collection at the
*document* level. i am not able to figure this out by reading the api. could
anyone help me here please?

many thanks,
-nani