Hi Christian,

Thank you for your valuable help!

With kind regards,
Menashè

On 04/30/2015 06:50 PM, Christian Grün wrote:
Hi Menashè,

The following query is really fast.
This should even be faster:

   let $ids := (161,891)
   for $id in $ids
   return db:open-id("collection_name", $id)

Should I use it also for thousands of
possible values instead of creating a temporal collection of the subset?
If the id approach does what you need, there is probably no need for
an additional collection. If you update your data, you may need to use
the UPDINDEX flag before creating the database; otherwise, id lookups
will be pretty slow.

Best,
Christian


let $ids := (161,891)
for $x in collection("collection_name")
where db:node-id($x)=$ids
return ...

With kind regards,
Menashè

On 04/30/2015 04:55 PM, Christian Grün wrote:

Hi Menashé,

If you want to directly address XML nodes of a BaseX database, you can
use the db:node-pre/db:open-pre or db:node-id/db:open-id functions.
Please have a look at the Wiki for more information [1].

Hope this helps,
Christian

[1] http://docs.basex.org/wiki/Database_Module#Read_Operations



On Thu, Apr 30, 2015 at 2:49 PM, Menashè Eliezer
<melie...@ogs.trieste.it> wrote:

Hello,
I'm using Java org.xmldb.api package for accessing the Basex server
(xmldb:basex://...)
After getting the resultSet I need to make further queries about the
requested subset (for reporting, etc.)
I have seen that getId() cannot be used since the Resource will be anonymous
if it is obtained as the result of a query.
Source: http://xmldb-org.sourceforge.net/xapi/api/index.html

The queries are not fixed and are based on end user selection.
I couldn't find a way to have a direct access/reference to a document. In my
case the ID is simply the filename, but it doesn't seem to be so efficient.
I wonder if creating a temporal collection for the subset would be faster
than making query/queries similar to the following example in which there
are only two ids, but I can have thousands of them:

let $ids := ('360836','300139')
for $x in collection("collection_name")
let $filename := substring-after(base-uri($x),'/')
let $id :=  substring-before($filename,'.')
where $id = $ids
return ...

--
With kind regards,
Menashè



Reply via email to