Skip to content

Commit

Permalink
Need to add authorization and remove a long deprecated data header se…
Browse files Browse the repository at this point in the history
…tting
  • Loading branch information
simar0at committed Oct 5, 2023
1 parent d6a288f commit 2e92b86
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vleserver/plugins/elasticsearch-update.offxqm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ declare namespace tei = "http://www.tei-c.org/ns/1.0";

declare variable $_:index-name := 'dboe';
(: for local testing use e.g.
docker run -e HTTP_PORT=9200 -e HTTPS_PORT=9300 -p 9200:9200 -p 9300:9300 --rm -t mendhak/http-https-echo:29 :)
docker run -e HTTP_PORT=9200 -e HTTPS_PORT=9300 -p 9200:9200 -p 9300:9300 --rm -t mendhak/http-https-echo:30 :)
declare variable $_:elasticsearch-bulk-href := 'http://localhost:9200/_bulk';
declare variable $_:elasticsearch-bulk-auth := 'Basic YmFzZXgtdXXXX==';
declare variable $_:xslt := 'entry-to-ag5-fields.xsl';
declare variable $_:log-elasticsearch-results := true();

Expand All @@ -32,7 +33,6 @@ declare function _:createNDJsonDataHeader($id as xs:string) as xs:string{
<json type="object">
<index type="object">
<__index>{$_:index-name}</__index>
<__type>_doc</__type>
<__id>{$id}</__id>
</index>
</json>,
Expand All @@ -56,6 +56,8 @@ declare function _:createNDJsonDataBody($data as element()) as xs:string {

declare function _:sendToElasticasearch($ndjsons as xs:string*) {
let $response := http:send-request(<http:request method="post">
<http:header name="User-Agent" value="vleserver-basex"/>
<http:header name="Authorization" value="{$_:elasticsearch-bulk-auth}"/>
<http:body media-type='application/x-ndjson'>{string-join($ndjsons, '&#x0a;')||'&#x0a;'}</http:body>
</http:request>, $_:elasticsearch-bulk-href)
return $response
Expand Down

0 comments on commit 2e92b86

Please sign in to comment.