|
From: Lars S. <sch...@sa...> - 2025-10-30 12:13:20
|
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 |