|
From: Joe W. <jo...@gm...> - 2026-10-28 04:22:04
|
[This response was prompted by Joe, drafted by Claude Code, and reviewed by
Joe.]
Hi Matthias,
I tried this on eXist 6.4.1 with a small package shaped like yours: a
`collection.xconf` at the root of the .xar, a `<finish>` script that logs
in and calls `xmldb:reindex`, and some data.
The finish script does run when the package is installed. But the reindex
has nothing to work with: eXist reads index configurations only from
`/db/system/config`, at the path that mirrors the collection, here
`/db/system/config/db/apps/coll/collection.xconf`. Installing a package
stores its `collection.xconf` in `/db/apps/coll` like any other file, where
it has no effect. So `xmldb:reindex` returns true, and no index is built.
The usual fix is a `<prepare>` script, which runs before the package's
files are stored, and copies the `.xconf` into place, so that the data is
indexed as it is stored and no reindex is needed:
```xml
<prepare>pre-install.xql</prepare>
```
```xquery
xquery version "3.1";
declare variable $target external;
declare variable $dir external;
(: create /db/system/config/db/apps/coll, one level at a time :)
let $_ := fold-left(tokenize(substring-after($target, "/db/"), "/"),
"/db/system/config/db",
function($parent, $name) { xmldb:create-collection($parent, $name) })
return
xmldb:store-files-from-pattern("/db/system/config" || $target, $dir,
"*.xconf")
```
`$target` (the collection the package is installed in) and `$dir` (the
directory the package was unpacked to) are passed to the script by the
installer. If you'd rather keep your finish script, storing `doc($target ||
"/collection.xconf")` into `/db/system/config` || `$target` before the call
to `xmldb:reindex` works too. I tested both ways: each gave a working index.
You don't need `xmldb:login` in either script, so no credentials need to go
in the .xar. The scripts run as the user who installs the package: in my
test, admin, installing with `repo:install-and-deploy-from-db`, without a
login in the script.
Best,
Joe
On Thu, Oct 22, 2026 at 7:37 AM Matthias Reinert <mat...@gm...>
wrote:
> Hi all,
> how do I trigger a re-indexing immediately after installing an application?
>
> I load an .xar file via launcher, its repo.xml has
>
> <finish>post-install.xql</finish>
>
> and post-install.xql is like:
>
> let $login := xmldb:login('/db/apps/coll', 'admin', 'pw')
> let $result := xmldb:reindex('/db/apps/coll')
> return
> <reindexed n="{$login}">{$result}</reindexed>
>
> post-install.xql is not called after unpacking the repo-xar according to
> Monex.
> It returns true called directly via (after running a while) but does not
> create an index, the same even without xmldb:login (which I would rather
> avoid admin credentials in xar-file).
>
> tested in 5.2.0, 6.0.1 and 6.4.1.
>
> any help is welcome.
> thanks,
> Matthias
> _______________________________________________
> Exist-open mailing list
> Exi...@li...
> https://lists.sourceforge.net/lists/listinfo/exist-open
>
|