Hi there,

via RESTXQ I request a vectorstore. The response is an JSON-Object.

For example:
With the following curl:

curl https://vector.io/query-data \

  -H "Authorization: Bearer ABcFMGhetc" \

  -d '{ "data": "Du hast dem Menschen ein so freies, herrliches und üppiges Leben bestimmt", "topK": 2, "includeVectors": false, "includeMetadata": true }'


I'm getting this object:


{

  "result" : [ {

    "id" : "ba02277",

    "score" : 0.9949091,

    "metadata" : {"genre":"ba","blatt":"1810-01","autor":"Kleist","titel":"Zoroaster.","link":"https://kleist-digital.de/etc","text":"freies, herrliches und üppiges Leben bestimmt."}

  }, {

    "id" : "ba01711",

    "score" : 0.8891792,

    "metadata" : {"genre":"ba","blatt":"1810-29","autor":"Ompteda","titel":"Fragmente","link":"https://kleist-digital.de/etc","text":"So mit dem Menschen im Moralischen."}

  } ]

}


1.

Is the request in my RESTXQ in the right form?

http:send-request(

        <http:request

            method="post"

            href="{$prod:url}/query-data">

            <http:header

                name="Authorization"

                value="Bearer {$prod:token}"/>

            <http:body

                media-type="application/json">

                {{

                "data": "{$query}",

                "topK": 20,

                "includeVectors": false,

                "includeMetadata": true

                }}

            </http:body>

        </http:request>

        )


2. 

I'm getting a full Object (but I dont know, if its the raw JSON-Object like above), but I am not able, to parse it, to get a list in html.

In the documentation https://docs.basex.org/wiki/JSON_Module is an example:

let $input := '{

  "Title": "Drinks",

  "Author": [ "Jim Daniels", "Jack Beam" ]

}'

let $data := json:parse($input, map { 'format': 'xquery' })

return map:for-each($data, function($k, $v) {

  $k || ': ' || string-join($v, ', ')

})


But my Object is more complex and I don't know, how to get two and more datasets with $k and $v out of the object. 

I want to have the following list:

<div>

<li>

<ul>

<li><span>Score: </span> <span>result score</span></li>

<li><span>Blatt: </span> <span>result blatt</span></li>

<li><span>Autor: </span> <span>result autor</span></li>

<li><span>Titel: </span> <span>result titel</span></li>

<li><span>Text: </span> <span>result text</span></li>

<li><span>Link: </span> <span>result link</span></li>

</ul>

</li>

<ul>

<li></li>

</ul>

etc.

</div>


Thanks for any help

Günter