collections

Create a new collection

When a collection is created, we give it a name and describe the fields that will be indexed from the documents added to the collection.

post/collections

Request body

namestring required

Name of the collection

default_sorting_fieldstring

The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity.

token_separatorsstring[]

List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.

enable_nested_fieldsboolean

Enables experimental support at a collection level for nested object or object array fields. This field is only available if the Typesense server is version 0.24.0.rcn34 or later.

symbols_to_indexstring[]

List of symbols or special characters to be indexed.

Example request

{
  "name": "companies",
  "fields": [
    {
      "name": "num_employees",
      "type": "int32",
      "facet": false
    },
    {
      "name": "company_name",
      "type": "string",
      "facet": false
    },
    {
      "name": "country",
      "type": "string",
      "facet": true
    }
  ],
  "default_sorting_field": "num_employees",
  "enable_nested_fields": true
}

Response

Collection successfully created

namestring required

Name of the collection

default_sorting_fieldstring

The name of an int32 / float field that determines the order in which the search results are ranked when a sort_by clause is not provided during searching. This field must indicate some kind of popularity.

token_separatorsstring[]

List of symbols or special characters to be used for splitting the text into individual words in addition to space and new-line characters.

enable_nested_fieldsboolean

Enables experimental support at a collection level for nested object or object array fields. This field is only available if the Typesense server is version 0.24.0.rcn34 or later.

symbols_to_indexstring[]

List of symbols or special characters to be indexed.

num_documentsinteger required

Number of documents in the collection

created_atinteger required

Timestamp of when the collection was created (Unix epoch in seconds)

Example response

{
  "name": "companies",
  "fields": [
    {
      "name": "num_employees",
      "type": "int32",
      "facet": false
    },
    {
      "name": "company_name",
      "type": "string",
      "facet": false
    },
    {
      "name": "country",
      "type": "string",
      "facet": true
    }
  ],
  "default_sorting_field": "num_employees",
  "enable_nested_fields": true
}

Changes