Skip to main content
GET
/
evaluate
/
query
/
{query_id}
JavaScript
import Hyperspell from '@hyperspell/hyperspell';

const client = new Hyperspell({
  apiKey: process.env['HYPERSPELL_API_KEY'], // This is the default and can be omitted
});

const queryResult = await client.evaluate.getQuery('query_id');

console.log(queryResult.query_id);
{
  "query_id": "<string>",
  "errors": [
    {}
  ],
  "documents": [
    {
      "resource_id": "<string>",
      "type": "<string>",
      "document": {
        "type": "document",
        "id": "<string>",
        "metadata": {
          "sources": [
            {
              "chunk_id": "<string>",
              "resource_id": "<string>",
              "source": "<string>",
              "score": 123
            }
          ],
          "edited_by": "<string>"
        },
        "text": "<string>",
        "children": [
          {
            "mimetype": "<string>",
            "data": "<string>",
            "type": "blob",
            "id": "<string>",
            "metadata": {
              "sources": [
                {
                  "chunk_id": "<string>",
                  "resource_id": "<unknown>",
                  "source": "<unknown>",
                  "score": "<unknown>"
                }
              ],
              "edited_by": "<string>"
            }
          }
        ],
        "title": "<string>"
      },
      "title": "<string>",
      "collection": "<string>",
      "metadata": {},
      "ingested_at": "2023-11-07T05:31:56Z",
      "last_modified_at": "2023-11-07T05:31:56Z",
      "document_date": "2023-11-07T05:31:56Z",
      "score": 123,
      "highlights": [
        "<unknown>"
      ],
      "summary": "<string>"
    }
  ],
  "answer": "<string>",
  "provenance": {
    "sources": [
      {
        "resource_id": "<string>",
        "title": "<string>",
        "score": 123
      }
    ],
    "entities": [
      {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "name": "<string>",
        "type": "<string>"
      }
    ],
    "failed_sources": [
      "<string>"
    ],
    "steps": [
      {
        "iteration": 123,
        "tool": "<string>",
        "status": "<string>",
        "query": "<string>",
        "source": "<string>",
        "result_count": 0
      }
    ]
  },
  "score": 123,
  "query": "<string>"
}

Authorizations

Authorization
string
header
required

API Key or JWT User Token. If using an API Key, set the X-As-User header to act as a specific user. A JWT User Token is always scoped to a specific user.

Path Parameters

query_id
string
required

Response

Successful Response

query_id
string | null

The ID of the query. This can be used to retrieve the query later, or add feedback to it. If the query failed, this will be None.

errors
Errors · object[] | null

Errors that occurred during the query. These are meant to help the developer debug the query, and are not meant to be shown to the user.

documents
ScoredDocumentResponse · object[]

The matching documents, each carrying its hyperdoc tree plus query-path score/highlights/summary (ENG-2479 Phase 4).

answer
string | null

The answer to the query, if the request was set to answer.

provenance
Provenance · object

Auditability record (source documents, entities, search trajectory, failed sources), if the request set provenance=True on a very_high query.

score
number | null

The average score of the query feedback, if any.

query
string | null

The query string that was issued.