Created
April 27, 2020 19:49
-
-
Save joewiz/321b5cf1fb549550e6022a90f69d3cff to your computer and use it in GitHub Desktop.
Generate eXist facet definitions for xconf index configuration files programmatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
(: WIP! :) | |
declare boundary-space preserve; | |
let $xconfs := | |
array { | |
map { | |
"qname": "tei:div", | |
"publication": "timeline", | |
"category": "department", | |
"url": "'/departmenthistory/timeline' || (if (@xml:id) then '/' || substring-after(./@xml:id, 'chapter_') else ())", | |
"path": "administrative-timeline/data/collection.xconf" | |
}, | |
map { | |
"qname": "tei:div", | |
"publication": "frus", | |
"category": "documents", | |
"url": "'/historicaldocuments/' || ancestor::tei:TEI/@xml:id || '/' || ./@xml:id", | |
"path": "administrative-timeline/data/collection.xconf", | |
"has-fulltext": "@type = ('section', 'document')" | |
}, | |
map { | |
"qname": "persName", | |
"publication": "pocom", | |
"category": "department", | |
"url": "'/departmenthistory/people/' || parent::person/id", | |
"path": "pocom/people/collection.xconf" | |
}, | |
map { | |
"qname": "trip", | |
"publication": "travels", | |
"category": "department", | |
"url": "'/departmenthistory/travels/president/' || util:document-name(.) => substring-before('.xml')", | |
"path": "travels/president/collection.xconf" | |
}, | |
map { | |
"qname": "trip", | |
"publication": "travels", | |
"category": "department", | |
"url": "'/departmenthistory/travels/secretary/' || util:document-name(.) => substring-before('.xml')", | |
"path": "travels/secretary/collection.xconf" | |
}, | |
map { | |
"qname": "visits", | |
"publication": "visits", | |
"category": "department", | |
"url": "'/departmenthistory/visits/' || year-from-date(./start-date)", | |
"path": "visits/data/collection.xconf" | |
} | |
} | |
for $xconf in $xconfs?* | |
return | |
map { | |
"uri": $xconf?uri, | |
"xconf": | |
<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> | |
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"> | |
<!-- Specify stop words - or remove them entirely --> | |
<param name="stopwords" type="org.apache.lucene.analysis.util.CharArraySet"> | |
<!--<value>the</value>--> | |
</param> | |
</analyzer> | |
<analyzer class="org.apache.lucene.analysis.core.KeywordAnalyzer" id="keyword"/> | |
<text qname="{$xconf?uri}" index="yes"> | |
<!-- start required facets and fields --> | |
<facet dimension="hsg-category" expression="'{$xconf?category}'"/> | |
<facet dimension="hsg-publication" expression="'{$xconf?publication}'"/> | |
<facet dimension="hsg-has-fulltext" expression="'true'"/> | |
<field name="hsg-fulltext"/>{if (map:contains($xconf, "fulltext")) then attribute expression {$xconf?fulltext} else ()} | |
<field name="hsg-url" expression="{$xconf?url}"/> | |
<!-- end required facets and fields --> | |
</text> | |
</lucene> | |
</index> | |
</collection> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment