Index field - Computed field function access to the same collection?
Lars Scheideler <[email protected]> Thu, 30 Oct 2025 12:43:46 +0100
| Newsgroups | gmane.text.xml.exist |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============4314566780357321190==
Content-Type: multipart/alternative;
boundary="------------o8gi7tN7MrVc3UKUZ0MtIX4A"
Content-Language: en-US, de-DE
This is a multi-part message in MIME format.
--------------o8gi7tN7MrVc3UKUZ0MtIX4A
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Hello,
I want to index a collection and need a field that contains specific
computed values from the same collection.
I have various TEI XML files with different biblStruct types. Some of
these files refer to other biblStructs via ref elements. I need the IDs
of the biblStructs that point to the current, indexed biblStruct.
However, when I reindex the collection, the fields almost exclusively
contain “empty” values.
Here the code:
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<lucene>
<module uri="http://application.de/xquery/facet-utils"
prefix="fu"
at="xmldb:exist:///db/apps/application/modules/index-facet-utils.xqm"/>
<text qname="tei:biblStruct">
<field name="workgroupid"
expression="fu:get-workgroup-id(.)"/>
</text>
</lucene>
</index>
</collection>
declare function fu:get-workgroup-id($biblStruct as element()) as
xs:string* {
let $corresp as xs:string := $biblStruct/@corresp/string()
let $workgroupsIds as xs:string* :=
collection("/db/projects/application/data/bibls")//tei:biblStruct[@type
eq 'dataset'][.//tei:ref[@type eq 'relDocRef']/@target/string() =
$corresp]/@xml:id/string()
let $workgroupsIdsJoined := string-join($workgroupsIds,';')
return
if($workgroupsIdsJoined ne "") then $workgroupsIdsJoined else
"empty"
};
I assume that I do not have access to the same collection that is
actually indexed or to specific attributes/elements (this case is not
described/addressed/mentioned in either the documentation or the book),
but the function takes far too long for live productive use.
Thanks for the help.
Best regards
--------------o8gi7tN7MrVc3UKUZ0MtIX4A
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p><font face="Source Sans 3">Hello,</font></p>
<p><font face="Source Sans 3">I want to index a collection and need
a field that contains specific computed values from the same
collection. <br>
I have various TEI XML files with different biblStruct types.
Some of these files refer to other biblStructs via ref elements.
I need the IDs of the biblStructs that point to the current,
indexed biblStruct.<br>
However, when I reindex the collection, the fields almost
exclusively contain “empty” values. </font></p>
<p><font face="Source Sans 3">Here the code: </font></p>
<p><font face="Source Sans 3"><collection
xmlns=<a class="moz-txt-link-rfc2396E" href="http://exist-db.org/collection-config/1.0">"http://exist-db.org/collection-config/1.0"</a>><br>
<index <a class="moz-txt-link-freetext" href="xmlns:tei=">xmlns:tei=</a><a class="moz-txt-link-rfc2396E" href="http://www.tei-c.org/ns/1.0">"http://www.tei-c.org/ns/1.0"</a>
xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>><br>
<lucene><br>
<module
uri=<a class="moz-txt-link-rfc2396E" href="http://application.de/xquery/facet-utils">"http://application.de/xquery/facet-utils"</a> prefix="fu"
at=<a class="moz-txt-link-rfc2396E" href="xmldb:exist:///db/apps/application/modules/index-facet-utils.xqm">"xmldb:exist:///db/apps/application/modules/index-facet-utils.xqm"</a>/><br>
<text qname=<a class="moz-txt-link-rfc2396E" href="tei:biblStruct">"tei:biblStruct"</a>><br>
<field name="workgroupid"
expression=<a class="moz-txt-link-rfc2396E" href="fu:get-workgroup-id(.)">"fu:get-workgroup-id(.)"</a>/><br>
</text><br>
</lucene><br>
</index><br>
</collection><br>
<br>
<br>
declare function <a class="moz-txt-link-freetext" href="fu:get-workgroup-id($biblStruct">fu:get-workgroup-id($biblStruct</a> as element())
as <a class="moz-txt-link-freetext" href="xs:string*">xs:string*</a> {<br>
let $corresp as <a class="moz-txt-link-freetext" href="xs:string">xs:string</a> := $biblStruct/@corresp/string()<br>
let $workgroupsIds as <a class="moz-txt-link-freetext" href="xs:string*">xs:string*</a> :=
collection("/db/projects/application/data/bibls")//<a class="moz-txt-link-freetext" href="tei:biblStruct">tei:biblStruct</a>[@type
eq 'dataset'][.//<a class="moz-txt-link-freetext" href="tei:ref">tei:ref</a>[@type eq 'relDocRef']/@target/string()
= $corresp]/@<a class="moz-txt-link-freetext" href="xml:id/string()">xml:id/string()</a><br>
let $workgroupsIdsJoined := string-join($workgroupsIds,';')<br>
return<br>
if($workgroupsIdsJoined ne "") then $workgroupsIdsJoined
else "empty"<br>
};</font></p>
<p><font face="Source Sans 3">I assume that I do not have access to
the same collection that is actually indexed or to specific
attributes/elements (this case is not
described/addressed/mentioned in either the documentation or the
book), but the function takes far too long for live productive
use. </font></p>
<p><font face="Source Sans 3">Thanks for the help.</font></p>
<p><font face="Source Sans 3">Best regards </font></p>
</body>
<lt-container></lt-container>
</html>
--------------o8gi7tN7MrVc3UKUZ0MtIX4A--
--===============4314566780357321190==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============4314566780357321190==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Exist-open mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/exist-open
--===============4314566780357321190==--