# Overview

Hyperstream manages the indexing component of the Streambased product suite. Using Hyperstream, users can create, delete and utilise indexes to accelerate analytical queries that run on Streambased components.&#x20;

Hyperstream is optimised for queries that return result sets that are small combined to the larger data set and clusters together (queries filtered by timestamp range are a great example of this).

Hyperstream exposes the following API:

***

**Fetch table schemas:**

Request:

```properties
POST /api/schema
{
    "set": "HOT" # the dataset to fetch schemas from (HOT/COLD/MERGED)
}
```

Response:

```properties
{
    "customers" : [  # a table
        {   # a field            
            "col_name": "Name",
            "data_type": "string",
            "comment" : ""
        } 
    ]
}
```

***

**Run query:**

Request:

```properties
POST /api/query
{
    "set": "HOT", # the dataset to run the query one (HOT/COLD/MERGED)
    "sql": "SELECT * FROM customers",  # the query to run
    "index": true,  # whether to use indexes to increase performance
}
```

Response:

```properties
[  # a list of rows
    { 
        "Name" : "Judith Gottlieb", # key/value pair representing column value
        "Age" : 42
    }        
]

```

***

**Create Index:**

Request:

```properties
PUT /api/index
{
  "topic": "customers" # the topic to index
  "field": "Name"  ## the field to index
}
```

Response:

```properties
HTTP 200

```

***

**Get index lag:**

The index lag represents the amount of new messages written since the topic was last indexed. Lag will not effect the correctness of results but will decrease query performance.

Request:

```properties
POST /api/index
{
  "topic": "customers" # the topic to index
  "field": "Name"  ## the field to index
}
```

Response:

```properties
{
  "record_lag" : 42  # the number of message behind
}
```

***

**Enrich a query:**

Enriching a query adds extra clauses to take advantage of indexing information available and increase query performance.

Request:

```properties
POST /api/enrich
{
  "sql" : "SELECT * FROM customers WHERE Name = 'Judith Gottlieb'"
}
```

Response:

```properties
{
  "originalSql" : "SELECT * FROM customers WHERE Name = 'Judith Gottlieb'"
  "enrichedSql" : "SELECT * FROM (SELECT *  FROM customers WHERE (( kafka_partition = 0 AND kafka_offset >= 334000 AND kafka_offset < 335000)) OR  (( kafka_partition = 0 AND kafka_offset >= 999999 )))  WHERE Name = 'Judith Gottlieb'"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.streambased.io/deploy-and-operate/streambased-platform/hyperstream/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
