Hi,
I would like to store the results of an xquery extracting some nodes from an existing database into a new database.
So I have the DB 'collect' open and then do:
db:create('annotate-abcdef')
and then
for $i at $p in //entry[phraseme[text() = "abcdef"] and selected[text() = "yes"]] let $query := $i/query let $nodeid := $i/node let $node := db:open-id('TG-DTA-GerManC-stemming-ws', $nodeid) let $nodename := name($node) let $nodecontent := string($node) return insert node <div>{$nodeid} {$query} {element {$nodename} {$nodecontent}} </div> as last into db:open('annotate-abcdef')
However, the error message is
[XUDY0027] Insert target must not be empty.
How would I add a root element to the new DB, as I don't wan't to link it to an existing document? All nodes added to the DB are only results from queries over an existing DB. All I can see from the Wiki is using a document as initial data for the DB.
How do I set UPDINDEX ON for the new DB? I will later update the information added in the first place by other queries. To be able to use ft:mark, I would have to optimize the DB with db:optimize() after having added nodes, is this correct?
Thanks in advance and best regards
Cerstin
Hi ,
Am 14.03.2013 um 19:11 schrieb Cerstin Elisabeth Mahlow cerstin.mahlow@unibas.ch:
How would I add a root element to the new DB, as I don't wan't to link it to an existing document? All nodes added to the DB are only results from queries over an existing DB. All I can see from the Wiki is using a document as initial data for the DB.
I now use a rather odd workaround:
db:create('annotate', <root/>, '/dev/null/')
I think it should be possible to create a DB with a root element only, not requiring a document.
As I want to use fulltext queries for this DB later, I created the fulltext index after inserting all nodes. It seems that one has to run OPTIMIZE first and only afterwards can create the fulltext index with CREATE INDEX. Is this correct? Or is it possible to create all indexes with one command?
When I update this DB later by letting users interact, do I have to run OPTIMIZE after every update to be able to use ft:mark for the following user interactions?
Thanks in advance
Cerstin
Hi Cerstin,
So I have the DB 'collect' open and then do: db:create('annotate-abcdef')
as you guessed, you’ll have to specify a document path, in which you can then add new nodes. Every XML document has a root node, and vice versa, so it’s conceptually not possible to only create a root node without a document. Please note, however, that your second argument is simply the name and path of your document, and does not read any input.
How do I set UPDINDEX ON for the new DB?
The following lines should do what you need:
declare option db:ftindex "on"; declare option db:updindex "on"; db:create('annotate', <root/>, 'root.xml')
If you activate the FTINDEX option before creating a database, the OPTIMIZE call will always create/update your full-text index.
To be able to use ft:mark, I would have to optimize the DB with db:optimize() after having added nodes, is this correct?
ft:mark() also works without full-text index, but the index solution is usually faster.
Christian
Hi Christian,
Am 18.03.2013 um 15:54 schrieb Christian Grün christian.gruen@gmail.com :
So I have the DB 'collect' open and then do: db:create('annotate-abcdef')
as you guessed, you’ll have to specify a document path, in which you can then add new nodes. Every XML document has a root node, and vice versa, so it’s conceptually not possible to only create a root node without a document. Please note, however, that your second argument is simply the name and path of your document, and does not read any input.
Ah, so I would better use
db:create('annotate-$name', <root/>, 'annotate-$name.xml')
Somehow it is not clear from the Wiki, I thought I had to use an existing document with some data in it. So this document does not have to exist before?
How do I set UPDINDEX ON for the new DB?
The following lines should do what you need:
declare option db:ftindex "on"; declare option db:updindex "on"; db:create('annotate', <root/>, 'root.xml')
If you activate the FTINDEX option before creating a database, the OPTIMIZE call will always create/update your full-text index.
Ah, I will try this.
To be able to use ft:mark, I would have to optimize the DB with db:optimize() after having added nodes, is this correct?
ft:mark() also works without full-text index, but the index solution is usually faster.
OK, since some of the DBs will have more than 400 entries, it is save to always optimize the index after updating.
Thanks and best regards
Cerstin
Am 18.03.2013 um 23:42 schrieb Christian Grün christian.gruen@gmail.com :
Somehow it is not clear from the Wiki, I thought I had to use an existing document with some data in it. So this document does not have to exist before?
Good to know. Edits in our Wiki are always welcome! ;)
And my assumption isn't true: The document has to exist, I cannot specify a non-existing document, i.e., a document I maybe would like to produce later as an export of the DB.
What I don't understand: Why do I have to specify a document when the content is not used? All I need is a fresh DB which I fill with "data" that maybe later will form a document.
So I stick with the /dev/null solution. It looks odd, but it works :)
Best regards
Cerstin
And my assumption isn't true: The document has to exist, I cannot specify a non-existing document, i.e., a document I maybe would like to produce later as an export of the DB.
This sounds surprising to me, as I don’t get any errors when running e.g. the following command..
basex "db:create('db', <root/>, 'doesnotexist.xml')"
How does your command call look like? Christian
Hi Christian,
Am 18.03.2013 um 23:53 schrieb Christian Grün christian.gruen@gmail.com:
And my assumption isn't true: The document has to exist, I cannot specify a non-existing document, i.e., a document I maybe would like to produce later as an export of the DB.
This sounds surprising to me, as I don’t get any errors when running e.g. the following command..
basex "db:create('db', <root/>, 'doesnotexist.xml')"
How does your command call look like?
It's in the cgi and it looks like this:
$session->execute("xquery declare option db:ftindex 'on'; declare option db:updindex 'on'; db:create('annotate-$phraseme', <root/>, 'annotate-$phraseme.xml')");
$phraseme holds the ID to be used.
But it's funny, it works today without error, but it didn't work two days ago. And I did not install any updates.
So it fixed itself, thanks!
Cerstin
basex-talk@mailman.uni-konstanz.de