Commit 4be60ddf authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

new config for facet module

parent d327b81d
......@@ -3,6 +3,7 @@ module namespace fsearch = "http://sade/faceted-search" ;
import module namespace kwic="http://exist-db.org/xquery/kwic";
import module namespace config="http://textgrid.de/ns/SADE/config" at "../config/config.xqm";
import module namespace console="http://exist-db.org/xquery/console";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace bol="http://blumenbach-online.de/blumenbachiana";
......@@ -16,7 +17,7 @@ declare function fsearch:results($node as node(), $model as map(*)) as map()* {
let $hits := local:get-hits($model, $target)
let $obreq := request:get-parameter("order-by", "relevance")
let $order-by := string-join($model("config")//module[@key="faceted-search"]//order[@key = $obreq]//xpath , ",")
let $order-by := string-join($config:configDoc//module[@key="faceted-search"]//order[@key = $obreq]//xpath , ",")
let $hitsordered :=
if(request:get-parameter("order", "descending") = "descending") then
......@@ -89,7 +90,7 @@ declare function fsearch:result-title($node as node(), $model as map(*)) {
return
<a href="{$viewdoc}{util:document-name($model("hit"))}">
{
for $titleQuery in $model("config")//module[@key="faceted-search"]/param[@key="result-title"]//xpath
for $titleQuery in $config:configDoc//module[@key="faceted-search"]/param[@key="result-title"]//xpath
return util:eval("($model('hit')" || $titleQuery || ")[1]")
}
</a>
......@@ -162,9 +163,10 @@ function fsearch:result-id($node as node(), $model as map(*)) {
};
declare function fsearch:facets($model as map(*), $hits) as map() {
let $test := console:log( $config:configDoc )
return
map:new(
for $facet in $model("config")//module[@key="faceted-search"]//facet
for $facet in $config:configDoc//module[@key="faceted-search"]//facet
return
map:entry(xs:string($facet/@key), local:facet($model, $hits, $facet/@key, $facet//xpath/text()))
)
......@@ -180,7 +182,7 @@ function fsearch:facet-title($node as node(), $model as map(*)) {
};
declare function fsearch:facet($node as node(), $model as map(*)) as item()* {
let $facets := $model("config")//module[@key="faceted-search"]//facet
let $facets := $config:configDoc//module[@key="faceted-search"]//facet
for $facet in $facets
(: hide facet-categories with less than one entry :)
......@@ -272,12 +274,13 @@ declare function local:get-hits($model as map(*), $target as xs:string) as node(
let $query := request:get-parameter("q", ())
let $fxquery := local:construct-facet-query($model)
let $options :=
let $options :=
<options>
<leading-wildcard>yes</leading-wildcard>
</options>
let $xqueries := for $query-root in $model("config")//module[@key="faceted-search"]/param[@key="query-root"]//xpath
let $xqueries := for $query-root in $config:configDoc//module[@key="faceted-search"]/param[@key="query-root"]//xpath
return
if($query) then
"collection($target)" || $query-root || $fxquery || "[ft:query(., $query, $options)]"
......@@ -297,7 +300,7 @@ declare function local:construct-facet-query($model as map(*)) as xs:string {
for $fquery in tokenize($facet, ",")
let $parts := tokenize($fquery, ":")
let $select :=
for $xpath in $model("config")//module[@key="faceted-search"]//facet[@key = $parts[1]]//xpath
for $xpath in $config:configDoc//module[@key="faceted-search"]//facet[@key = $parts[1]]//xpath
let $val := xmldb:decode($parts[2])
let $op := if(starts-with($val, "!"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment