View Source Typesense.Collections (ecto_typesense v0.9.0)

Methods for interaction with Typesense collections.

Link to this section Summary

Functions

Create a Collection.

Delete a collection.

List all collections.

Retrieve a collection.

Link to this section Types

@type schema() :: %{
  :name => String.t(),
  :fields => [
    %{
      :name => String.t(),
      :type => String.t(),
      optional(:facet) => boolean(),
      optional(:optional) => boolean()
    }
  ],
  optional(:default_sorting_field) => integer()
}

Link to this section Functions

@spec create(schema()) :: {:ok, map()} | {:error, map()}

Create a Collection.

examples

Examples

schema = %{
  name: "companies",
  fields: [
    %{name: "company_name", type: "string"},
    %{name: "num_employees", type: "int32"},
    %{name: "country", type: "string", facet: true},
  ],
  default_sorting_field: "num_employees"
}
Typesense.Collections.create(schema)
@spec delete(binary()) :: {:ok, any()} | {:error, any()}

Delete a collection.

examples

Examples

iex> Typesense.Collections.delete(collection_id)
{:ok, _collection}
@spec list() :: {:ok, list()} | {:error, any()}

List all collections.

examples

Examples

iex> Typesense.Collections.list()
{:ok, collections}
@spec retrieve(binary()) :: {:ok, map()} | {:error, any()}

Retrieve a collection.

examples

Examples

iex> Typesense.Collections.retrieve("companies")
{:ok, company}