> For the complete documentation index, see [llms.txt](https://docs.streambased.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.streambased.io/deploy-and-operate/streambased-platform/hyperstream/overview.md).

# 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'"
}
```
