> 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/flows/setting-up/creating-a-collection.md).

# Creating a Collection

The Hyperspace database stores data within Collections, which are distinct segments within the database.

Hyperspace collections act like data containers, housing a large amount of data to be stored together and then accessed.

To enable the usage of the commands described below, you must first create a local Hyperspace instance to ensure the availability of necessary resources and functionalities.

**Copy the following code snippet to create a collection –**

{% tabs %}
{% tab title="Python" %}
{% code lineNumbers="true" %}

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

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
String collectionName = "new_collection";
JsonObject schema = (JsonObject) 
JsonParser.parseReader(new FileReader("schema.json"));
client.createCollection(collectionName, schema);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
const collection_name = 'new_collection';
await hyperspaceClient.indices.create({
    index: collectionName,
    body: 'schema.json'
})
```

{% endcode %}
{% endtab %}
{% endtabs %}

Where –

* <mark style="color:purple;">'schema.json'</mark> – Specifies the path to the configuration file (for example, '\schema.json') that you created locally on your machine, as described in [Creating a Database Schema Configuration File.](https://docs.hyper-space.io/hyperspace-docs/projects/setting-up/creating-a-database-schema-configuration-file)
* <mark style="color:purple;">collection\_name</mark> – Specifies the name of the collection to be created in the Hyperspace database. You can specify any name as long as it is unique to your Hyperspace Collection.

**Response**

The following response should be received –

*{'status': 'OK', 'code': 200, 'message': 'Collection was successfully created'}*

Alternatively, you can also define the config schema as a python dictionary .

**Example -**&#x20;

{% tabs %}
{% tab title="Python" %}
{% code lineNumbers="true" %}

```json
config_schema = {
  "configuration": {
    "budget": {
      "type": "integer"
    },
    "genres": {
      "struct_type": "list",
      "type": "keyword"
    },
    "id": {
      "type": "keyword",
      "id": True
    },   
    "popularity": {
      "type": "float"
    },
    "rating": {
      "type": "float"
    },
    "release_date_unix_time": {
      "type": "date"
    },  
     "embedded_overview": {
            "type": "dense_vector",
            "dim": 384,
            "index_type": "brute_force",
            "metric": "IP"
      }
  }
}

collection_name = 'new_collrction"

hyperspace_client.create_collection(config_schema, collection_name)
```

{% endcode %}

{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
String configSchema = "{"
                       " \"configuration\": {" + 
                       "   \"budget\": {" +
                       "      \"type\": \"integer\"" +
                       "    }," +
                       "     \"genres\": {" +
                       "       \"struct_type\": \"list\"," +
                       "       \"type\": \"keyword\"" +
                       "     }," +
                       "     \"id\": {" +
                       "       \"type\": \"keyword\"," +
                       "       \"id\": True" +
                       "     },   " +
                       "     \"popularity\": {" +
                       "       \"type\": \"float\"" +
                       "     }," +
                       "     \"rating\": {" +
                       "       \"type\": \"float\"" +
                       "     }," +
                       "     \"release_date_unix_time\": {" +
                       "       \"type\": \"date\"" +
                       "     },  " +
                       "      \"embedded_overview\": {" +
                       "             \"type\": \"dense_vector\"," +
                       "             \"dim\": 384," +
                       "             \"index_type\": \"brute_force\"," +
                       "             \"metric\": \"IP\"" +
                       "       }" +
                       "   }" +
                       " }";
hyperspaceClient.createCollection(collectionName, schema);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}

<pre class="language-javascript" data-line-numbers><code class="lang-javascript">const configSchema = {
  "configuration": {
    "budget": {
      "type": "integer"
    },
    "genres": {
      "struct_type": "list",
      "type": "keyword"
    },
    "id": {
      "type": "keyword",
      "id": true
    },   
    "popularity": {
      "type": "float"
    },
    "rating": {
      "type": "float"
    },
    "release_date_unix_time": {
      "type": "date"
    },  
     "embedded_overview": {
            "type": "dense_vector",
            "dim": 384,
            "index_type": "brute_force",
            "metric": "IP"
      }
  }
<strong>};
</strong>
const collectionName = "new_collection";

hyperspace_client.createCollection(configSchema, collectionName );
</code></pre>

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Collections (sometimes referred to as "indexes") are a fundamental concept in databases that may organize data as Collections of documents. Collection's documents have a general predefined structure, but each document within a Collection can have its own unique set of fields and data out of the schema. Serving as containers for related documents and records, Collections facilitate logical grouping, making it simpler to organize, manage, and efficiently query, index, and retrieve related data.
{% endhint %}


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.hyper-space.io/hyperspace-docs/flows/setting-up/creating-a-collection.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
