Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SADE
SADE
Commits
4be60ddf
Commit
4be60ddf
authored
May 10, 2017
by
Mathias Goebel
Browse files
new config for facet module
parent
d327b81d
Changes
1
Hide whitespace changes
Inline
Side-by-side
modules/faceted-search/faceted-search.xqm
View file @
4be60ddf
...
...
@@ -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:
config
Doc
//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:
config
Doc
//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:
config
Doc
//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:
config
Doc
//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:
config
Doc
//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:
config
Doc
//module[@key="faceted-search"]//facet[@key = $parts[1]]//xpath
let $val := xmldb:decode($parts[2])
let $op := if(starts-with($val, "!"))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment