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
ARCHITRAVE
SADE
Commits
0c54bea6
Commit
0c54bea6
authored
Sep 24, 2020
by
Moritz Schepp
Browse files
highlight fixes
parent
c1cf8abe
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
helpers/redindex.xq
View file @
0c54bea6
xquery
version
"3.1"
;
(:xmldb:reindex('/db/apps/sade-architrave'):)
import
module
namespace
elastic
=
"http://elastic.io"
at
"elastic.xqm"
;
elastic:setup
()
import
module
namespace
elastic
=
"http://elastic.io"
at
"../modules/elastic.xqm"
;
let
$r
:=
elastic:setup
()
return
$r
modules/api.xq
View file @
0c54bea6
...
...
@@ -39,7 +39,17 @@ declare function local:search-editions-elastic() {
}
,
"highlight"
:
map
{
"fragment_size"
:
100
,
"require_field_match"
:
fn:false
()
,
"pre_tags"
:
[
'<span class="hl">'
]
,
"post_tags"
:
[
'</span>'
]
,
"type"
:
"plain"
,
"highlight_query"
:
map
{
"query_string"
:
map
{
"query"
:
$terms
}
}
,
"fields"
:
map
{
"name"
:
map
{
"number_of_fragments"
:
0
}
,
"search_data"
:
map
{}
}
}
...
...
@@ -68,6 +78,15 @@ declare function local:search-pages-elastic() {
}
,
"highlight"
:
map
{
"fragment_size"
:
100
,
"require_field_match"
:
fn:false
()
,
"pre_tags"
:
[
'<span class="hl">'
]
,
"post_tags"
:
[
'</span>'
]
,
"type"
:
"plain"
,
"highlight_query"
:
map
{
"query_string"
:
map
{
"query"
:
$terms
}
}
,
"fields"
:
map
{
"search_data"
:
map
{}
}
...
...
@@ -94,7 +113,13 @@ declare function local:search-register-elastic($type) {
}
,
"highlight"
:
map
{
"fragment_size"
:
100
,
"require_field_match"
:
fn:false
()
,
"pre_tags"
:
[
'<span class="hl">'
]
,
"post_tags"
:
[
'</span>'
]
,
"type"
:
"plain"
,
"fields"
:
map
{
"name.de"
:
map
{
"number_of_fragments"
:
0
}
,
"name.fr"
:
map
{
"number_of_fragments"
:
0
}
,
"search_data.de"
:
map
{}
,
"search_data.fr"
:
map
{}
}
...
...
modules/elastic.xqm
View file @
0c54bea6
...
...
@@ -62,6 +62,13 @@ declare function elastic:index-doc($index, $id, $doc) {
return $response
};
declare function elastic:refresh() {
let $response := http:send-request(
<http:request method="GET" href="{$elastic:uri}/_refresh" />
)
return $response
};
declare function elastic:index-person($person) {
let $doc := map {
"id": string($person/@xml:id),
...
...
@@ -109,8 +116,12 @@ declare function elastic:index-work($work) {
};
declare function elastic:index-edition-page($page, $locale) {
let $uri := string($page//xhtml:span[@id='tei-meta-textGridURI']/text())
let $edition := fn:tokenize($uri, '[:\.]')[2]
let $page_number := xs:integer($page//xhtml:span[@class='pb']/text())
let $doc := map {
"id": string($page//xhtml:span[@id='tei-meta-textGridURI']/text()),
"id": concat('edition-', $edition, '-', $page_number),
"edition": $edition,
"page_number": xs:integer($page//xhtml:span[@class='pb']/text()),
"locale": $locale,
"name": string($page//xhtml:h4[starts-with(@id, 'tei-title-main-')][1]),
...
...
@@ -125,6 +136,7 @@ declare function elastic:index-wiki-page($page, $locale) {
let $parts := fn:tokenize($doc_name, '[_\.]')
let $elastic_id := concat($parts[1], '_', $parts[2])
let $doc := map {
"uri": $uri,
"id": $parts[1],
"locale": $parts[2],
"name": data($page//h1),
...
...
@@ -193,6 +205,7 @@ declare function elastic:setup() {
elastic:create-index("edition_pages", map {"mappings": map {
"properties": map {
"id": map {"type": "keyword", "index": fn:false()},
"edition": map {"type": "keyword", "index": fn:false()},
"page_number": map {"type": "integer"},
"locale": map {"type": "keyword"},
"name": map {"type": "text"},
...
...
@@ -209,11 +222,13 @@ declare function elastic:setup() {
for $doc in collection(concat($config:app-root, '/templates/register'))//tei:item
return elastic:index-work($doc),
for $doc in $editions_de/xhtml:div
return elastic:index-edition-page($doc, "de"),
for $doc in $editions_de/xhtml:div
return elastic:index-edition-page($doc, "de"),
for $doc in $editions_fr/xhtml:div
return elastic:index-edition-page($doc, "fr")
for $doc in $editions_fr/xhtml:div
return elastic:index-edition-page($doc, "fr"),
elastic:refresh()
]
return $r
...
...
templates/js/search.js
View file @
0c54bea6
This diff is collapsed.
Click to expand it.
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