xml-xindice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <va...@reverycodes.com>
Subject Re: Query Help
Date Sun, 25 Jul 2010 22:35:56 GMT
On Jul 23, 2010, at 11:43 AM, Liz Glasser wrote:

> I have a ton of records in my xindice database that look like:
> <MyRootElement myId="...">.....</MyRootElement>
> I need the most efficient way to get a list of all values for myId. How can I best do
> Basically if this was a relational database and I had a table called MyRootElement, I'd
do "select myId from MyRootElement". I need a xindice equivalent.

Hey Liz,

The query you are looking for is "/MyRootElement/@myId". Using command line you can query
it like this (replace /db/my/collection with path to your collection):

  xindice xpath -c /db/my/collection -q /MyRootElement/@myId

Results should look like:

  <xq:result xmlns:xq="http://xml.apache.org/xindice/Query" myId="value" xq:col="/db/my/collection"
xq:key="MyDocument1" />

Now, if only some % of documents in this collection contain this root element/attribute, then
you can speed that query up by build an index on the element/attribute pair. Index will allow
query engine to skip documents which do not have that element/attribute pair. Index also helps
if you want to find a document by value of the myId attribute. Command to build the index
looks like:

  xindice add_indexer -c /db/my/collection -n MyRootElementMyId -p MyRootElement@ myId

OTOH, if all documents have the same structure, then in order to extract all of the values,
query engine will have to iterate through all of the documents in the collection - and index
will be of no help.

Hope that helps.


View raw message