Typesensory.Api.Collections (Typesensory v0.1.0)

API calls for all endpoints tagged Collections.

Link to this section Summary

Functions

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.

Delete a collection Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies.

Retrieve an alias Find out which collection an alias points to by fetching it

List all aliases List all aliases and the corresponding collections that they map to.

Retrieve a single collection Retrieve the details of a collection, given its name.

List all collections Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first.

Update a collection Update a collection's schema to modify the fields and their types.

Create or update a collection alias Create or update a collection alias. An alias is a virtual collection name that points to a real collection. If you're familiar with symbolic links on Linux, it's very similar to that. Aliases are useful when you want to reindex your data in the background on a new collection and switch your application to it without any changes to your code.

Link to this section Functions

Link to this function

create_collection(connection, collection_schema, opts \\ [])

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.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_schema (CollectionSchema): The collection object to be created
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.CollectionResponse.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

delete_alias(connection, alias_name, opts \\ [])

@spec delete_alias(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.CollectionAlias.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Delete an alias

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • alias_name (String.t): The name of the alias to delete
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.CollectionAlias.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

delete_collection(connection, collection_name, opts \\ [])

@spec delete_collection(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.CollectionResponse.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Delete a collection Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to delete
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.CollectionResponse.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_alias(connection, alias_name, opts \\ [])

Retrieve an alias Find out which collection an alias points to by fetching it

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • alias_name (String.t): The name of the alias to retrieve
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.CollectionAlias.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_aliases(connection, opts \\ [])

@spec get_aliases(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Typesensory.Model.CollectionAliasesResponse.t()}
  | {:error, Tesla.Env.t()}

List all aliases List all aliases and the corresponding collections that they map to.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.CollectionAliasesResponse.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_collection(connection, collection_name, opts \\ [])

@spec get_collection(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.CollectionResponse.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Retrieve a single collection Retrieve the details of a collection, given its name.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to retrieve
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.CollectionResponse.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

get_collections(connection, opts \\ [])

@spec get_collections(
  Tesla.Env.client(),
  keyword()
) :: {:ok, [Typesensory.Model.CollectionResponse.t()]} | {:error, Tesla.Env.t()}

List all collections Returns a summary of all your collections. The collections are returned sorted by creation date, with the most recent collections appearing first.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, [%CollectionResponse{}, ...]} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

update_collection(connection, collection_name, collection_update_schema, opts \\ [])

Update a collection Update a collection's schema to modify the fields and their types.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • collection_name (String.t): The name of the collection to update
  • collection_update_schema (CollectionUpdateSchema): The document object with fields to be updated
  • opts (keyword): Optional parameters

returns

Returns

  • {:ok, Typesensory.Model.CollectionUpdateSchema.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

upsert_alias(connection, alias_name, opts \\ [])

@spec upsert_alias(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Typesensory.Model.CollectionAlias.t()}
  | {:ok, Typesensory.Model.ApiResponse.t()}
  | {:error, Tesla.Env.t()}

Create or update a collection alias Create or update a collection alias. An alias is a virtual collection name that points to a real collection. If you're familiar with symbolic links on Linux, it's very similar to that. Aliases are useful when you want to reindex your data in the background on a new collection and switch your application to it without any changes to your code.

parameters

Parameters

  • connection (Typesensory.Connection): Connection to server
  • alias_name (String.t): The name of the alias to create/update
  • opts (keyword): Optional parameters
    • :body (CollectionAliasSchema): Collection alias to be created/updated

returns

Returns

  • {:ok, Typesensory.Model.CollectionAlias.t} on success
  • {:error, Tesla.Env.t} on failure