Commit 0c54bea6 authored by Moritz Schepp's avatar Moritz Schepp
Browse files

highlight fixes

parent c1cf8abe
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
......@@ -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 {}
}
......
......@@ -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
......
This diff is collapsed.
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