Commit d6be45e4 authored by Moritz Schepp's avatar Moritz Schepp
Browse files

fixes elastic index creation

parent 0602e779
......@@ -29,6 +29,7 @@ declare function elastic:drop-index($index) {
let $response := http:send-request(
<http:request method="DELETE" href="{$elastic:uri}/{$elastic:prefix}{$index}" />
)
let $ok := elastic:require_ok($response)
return $response
};
......@@ -39,6 +40,7 @@ declare function elastic:create-index($index, $data) {
<http:body media-type="application/json" method="text">{$json}</http:body>
</http:request>
)
let $ok := elastic:require_ok($response)
return $response
};
......@@ -49,6 +51,7 @@ declare function elastic:index-doc($index, $doc) {
<http:body media-type="application/json" method="text">{$json}</http:body>
</http:request>
)
let $ok := elastic:require_ok($response)
return $response
};
......@@ -59,6 +62,7 @@ declare function elastic:index-doc($index, $id, $doc) {
<http:body media-type="application/json" method="text">{$json}</http:body>
</http:request>
)
let $ok := elastic:require_ok($response)
return $response
};
......@@ -66,6 +70,7 @@ declare function elastic:refresh() {
let $response := http:send-request(
<http:request method="GET" href="{$elastic:uri}/_refresh" />
)
let $ok := elastic:require_ok($response)
return $response
};
......@@ -147,6 +152,18 @@ declare function elastic:index-wiki-page($page, $locale) {
return elastic:index-doc('wiki_pages', $elastic_doc_id, $doc)
};
declare function elastic:require_ok($response) {
let $code := xs:integer($response[1]/@status)
return
if ($code < 200 or $code > 299) then
let $body := util:base64-decode($response[2])
let $name := QName('http://datypic.com/err', 'ProdNumReq')
let $msg := concat("(", string($code), ") elasticsearch responded with:", $body)
return fn:error($name, $msg)
else
fn:true()
};
declare function elastic:to_json($data) {
let $result := fn:serialize($data, map { 'method': 'json'})
return $result
......@@ -170,18 +187,20 @@ declare function elastic:setup() {
concat($config:app-root, '/templates/3czn9') (: knesebeck :)
)
let $register_mappings := map {
"properties": map {
"id": map {"type": "keyword", "index": fn:false()},
"name": map {
"properties": map {
"de": map {"type": "text", "index": fn:false()},
"fr": map {"type": "text", "index": fn:false()}
}
},
"search_data": map {
"properties": map {
"de": map {"type": "text"},
"fr": map {"type": "text"}
"_doc": map {
"properties": map {
"id": map {"type": "keyword", "index": fn:false()},
"name": map {
"properties": map {
"de": map {"type": "text", "index": fn:false()},
"fr": map {"type": "text", "index": fn:false()}
}
},
"search_data": map {
"properties": map {
"de": map {"type": "text"},
"fr": map {"type": "text"}
}
}
}
}
......@@ -197,21 +216,25 @@ declare function elastic:setup() {
elastic:create-index("places", map {"mappings": $register_mappings}),
elastic:create-index("works", map {"mappings": $register_mappings}),
elastic:create-index("wiki_pages", map {"mappings": map {
"properties": map {
"id": map {"type": "keyword", "index": fn:false()},
"locale": map {"type": "keyword"},
"name": map {"type": "text"},
"search_data": map {"type": "text"}
"_doc": map {
"properties": map {
"id": map {"type": "keyword", "index": fn:false()},
"locale": map {"type": "keyword"},
"name": map {"type": "text"},
"search_data": map {"type": "text"}
}
}
}}),
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"},
"search_data": map {"type": "text"}
"_doc": 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"},
"search_data": map {"type": "text"}
}
}
}}),
......
......@@ -66,8 +66,6 @@ export class ArchSearchResult extends React.Component {
}
name() {
console.log(this.props.data)
if (this.isType('register')) {
const d = this.props.data
......
This diff is collapsed.
Supports Markdown
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