> For the complete documentation index, see [llms.txt](https://docs.hyper-space.io/hyperspace-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyper-space.io/hyperspace-docs/~/changes/uCQNjcW7J3OXknfYJaVa/getting-started/quick-start.md).

# Quick Start

To start using Hyperspace, follow these steps:

### 1. Installing the Hyperspace API Client

Run the following shell command in your code or your data terminal –

```python
pip install git+https://github.com/hyper-space-io/hyperspace-py
```

for more information, see [here](https://docs.hyper-space.io/hyperspace-docs/projects/setting-up/installing-the-hyperspace-api-client).

### **2. Creating a local instance of the Hyperspace client**&#x20;

Once you receive credentials and host address, use the following code to connect to the database through the Hyperspace API.

```python
hyperspace_client = hyperspace.HyperspaceClientApi(host=host_address,
                                                      username=username,
                                                      password=password)
```

### **3. Running Hyperspace queries**

**Create a schema file**

The schema files outline the data structure, index and metric types, and similar configurations. More info can be found in the [configuration file](https://docs.hyper-space.io/hyperspace-docs/projects/setting-up/creating-a-database-schema-configuration-file) section.&#x20;

**Create a collection**

Copy the following code snippet to create a collection

```python
hyperspace_client.create_collection('schema.json', 'collection_name')
```

Where –

* '**schema.json**' – Specifies the path to the configuration file that you created locally on your machine.
* '**collection\_name**' – Specifies the name of the collection to be created in the Hyperspace database.&#x20;

**Upload Data**&#x20;

Data can be uploaded in batches. Copy the following code snippet to upload data

```python
BATCH_SIZE = 250
batch = []
for i, data_point in enumerate(documents):
   batch.append(data_point)
   if (i+1) % BATCH_SIZE == 0:
      response = hyperspace_client.add_batch(batch, collection_name)
      batch.clear()
if batch:
  response = hyperspace_client.add_batch(batch, collection_name)
hyperspace_client.commit(collection_name)
```

**Where** –

* <mark style="color:purple;">data\_point</mark> – Represents the document to upload. Each document must have dictionary like structure with a keys according to the database schema configuration file.
* <mark style="color:purple;">BATCH\_SIZE</mark> – Specifies the number of documents in a batch.
* `commit` is required for vector search only

**Build and run a query**

Hyperspace queries are one of the following types of search –

* **Classic Search**
* **Vector Search**
* **Hybrid Search**&#x20;

Classic and hybrid search require a [score function](https://docs.hyper-space.io/hyperspace-docs/projects/score-function-commands) of the following form:

<pre class="language-python"><code class="lang-python"><strong> def score_function (params , doc) :
</strong>    score = 0.0
    if match ('metadata field 1'):
       score = 1.0
       if match ('metadata field 1'):
          score 2.0
 return score
</code></pre>

Specify that this score function file is to be used for the Classic Search, as follows –

```python
hyperspace_client.set_function(score_function_filename,
                                collection_name=collection_name,
                                function_name='score_function')
```

**To run a hybrid search query –**

define the query schema and run&#x20;

```python
results = hyperspace_client.search({'params': query_body},
                                   size=5,                 
                                   collection_name=collection_name
                                   function_name='score_function')
```

`query_body` must have a similar structure to the database documents, according to the query schema config file. If query\_body includes fields of type&#x20;

**Retrieve Results**

To retrieve results, use the following command

```
results = hyperspace_client.search(vector_query_schema, size=5,   collection_name=collection_name)                 
```

**results** is a dictionary has two keys – {'similarity': {}, 'took\_ms'}

* **took\_ms** – is a float value that specifies how long the query took to run, such as 8.73ms
* **similarity** – Returns a list. Each element of the list represents a matching document. For each document, it specifies the score and the vector\_id that you can use to retrieve the document from the Collection.

Here is an example of what results might look like if they were printed on the screen –

```python
print(results)['similarity']) 
```

\[{'score: 513.7000122070312, 'vector\_id': '78254'},\
&#x20;{'score: 512.5500126784442, 'vector\_id': '23091'},\
&#x20;{'score: 485.5471220787652, 'vector\_id': '85432'}]

&#x20;a more detailed guide is available [here](https://docs.hyper-space.io/hyperspace-docs/projects/setting-up).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.hyper-space.io/hyperspace-docs/~/changes/uCQNjcW7J3OXknfYJaVa/getting-started/quick-start.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.
