OpenApiTypesense.Collections (OpenApiTypesense v0.6.5)
View SourceProvides API endpoints related to collections
Summary
Functions
Create a new collection
Either one of
Either one of
Delete an alias
Either one of
Either one of
Delete a collection
Either one of
Either one of
Retrieve an alias
Either one of
Either one of
List all aliases
Either one of
Either one of
Retrieve a single collection
Either one of
Either one of
List all collections
Either one of
Either one of
Update a collection
Either one of
Either one of
Create or update a collection alias
Either one of
Either one of
Functions
@spec create_collection(map()) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
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.
Options
src_name
: Clone an existing collection's schema (documents are not copied), overrides and synonyms. The actual documents in the collection are not copied, so this is primarily useful for creating new collections from an existing reference template.
Example
iex> schema = %{
...> "name" => "houses",
...> "fields" => [
...> %{"name" => "house_type", "type" => "string"},
...> %{"name" => "houses_id", "type" => "int32"},
...> %{"name" => "description", "type" => "string"},
...> ],
...> "default_sorting_field" => "houses_id",
...> }
iex> OpenApiTypesense.Collections.create_collection(schema)
@spec create_collection(map() | OpenApiTypesense.Connection.t(), map() | keyword()) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
create_collection(schema, opts)
create_collection(%{api_key: xyz, host: ...}, schema)
create_collection(Connection.new(), schema)
@spec create_collection(map() | OpenApiTypesense.Connection.t(), map(), keyword()) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
create_collection(%{api_key: 123, host: ...}, schema, opts)
create_collection(Connection.new(), schema, opts)
@spec delete_alias(String.t()) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Delete an alias
@spec delete_alias( String.t() | map() | OpenApiTypesense.Connection.t(), String.t() | keyword() ) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
delete_alias(aliasName, opts)
delete_alias(%{api_key: 123, host: ...}, aliasName)
delete_alias(Connection.new(), aliasName)
@spec delete_alias(map() | OpenApiTypesense.Connection.t(), String.t(), keyword()) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
delete_alias(%{api_key: 123, host: ...}, aliasName, opts)
delete_alias(Connection.new(), aliasName, opts)
@spec delete_collection(String.t()) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Delete a collection
Permanently drops a collection. This action cannot be undone. For large collections, this might have an impact on read latencies.
@spec delete_collection( String.t() | map() | OpenApiTypesense.Connection.t(), String.t() | keyword() ) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
delete_collection(collectionName, opts)
delete_collection(%{api_key: 123, host: ...}, collectionName)
delete_collection(Connection.new(), collectionName)
@spec delete_collection( map() | OpenApiTypesense.Connection.t(), String.t(), keyword() ) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
delete_collection(%{api_key: 123, host: ...}, collectionName, opts)
delete_collection(Connection.new(), collectionName, opts)
@spec get_alias(String.t()) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Retrieve an alias
Find out which collection an alias points to by fetching it
@spec get_alias( String.t() | map() | OpenApiTypesense.Connection.t(), String.t() | keyword() ) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
get_alias(aliasName, opts)
get_alias(%{api_key: 123, host: ...}, aliasName)
get_alias(Connection.new(), aliasName)
@spec get_alias(map() | OpenApiTypesense.Connection.t(), String.t(), keyword()) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
get_alias(%{api_key: 123, host: ...}, aliasName, opts)
get_alias(Connection.new(), aliasName, opts)
@spec get_aliases() :: {:ok, OpenApiTypesense.CollectionAliasesResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
List all aliases
List all aliases and the corresponding collections that they map to.
@spec get_aliases(map() | OpenApiTypesense.Connection.t() | keyword()) :: {:ok, OpenApiTypesense.CollectionAliasesResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
get_aliases(opts)
get_aliases(%{api_key: 123, host: ...})
get_aliases(Connection.new())
@spec get_aliases( map() | OpenApiTypesense.Connection.t(), keyword() ) :: {:ok, OpenApiTypesense.CollectionAliasesResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
get_aliases(%{api_key: 123, host: ...}, opts)
get_aliases(Connection.new(), opts)
@spec get_collection(String.t()) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Retrieve a single collection
Retrieve the details of a collection, given its name.
@spec get_collection( map() | OpenApiTypesense.Connection.t() | String.t(), String.t() | keyword() ) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
get_collection(collectionName, opts)
get_collection(%{api_key: 123, host: ...}, collectionName)
get_collection(Connection.new(), collectionName)
@spec get_collection(map() | OpenApiTypesense.Connection.t(), String.t(), keyword()) :: {:ok, OpenApiTypesense.CollectionResponse.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
get_collection(%{api_key: 123, host: ...}, collectionName, opts)
get_collection(Connection.new(), collectionName, opts)
@spec get_collections() :: {:ok, [OpenApiTypesense.CollectionResponse.t()]} | {:error, OpenApiTypesense.ApiResponse.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.
Options
limit
: Limit results in paginating on collection listing.offset
: Skip a certain number of results and start after that.exclude_fields
: Exclude the field definitions from being returned in the response.
@spec get_collections(map() | OpenApiTypesense.Connection.t() | keyword()) :: {:ok, [OpenApiTypesense.CollectionResponse.t()]} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
get_collections(Connection.new())
get_collections(%{api_key: xyz, host: ...})
get_collections(exclude_fields: "fields", limit: 10)
@spec get_collections( map() | OpenApiTypesense.Connection.t(), keyword() ) :: {:ok, [OpenApiTypesense.CollectionResponse.t()]} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
get_collections(%{api_key: 123, host: ...}, opts)
get_collections(Connection.new(), opts)
@spec update_collection(String.t(), map()) :: {:ok, OpenApiTypesense.CollectionUpdateSchema.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Update a collection
Update a collection's schema to modify the fields and their types.
@spec update_collection( map() | OpenApiTypesense.Connection.t(), String.t() | map(), map() | keyword() ) :: {:ok, OpenApiTypesense.CollectionUpdateSchema.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
update_collection(collectionName, body, opts)
update_collection(%{api_key: 123, host: ...}, collectionName, body)
update_collection(Connection.new(), collectionName, body)
@spec update_collection( map() | OpenApiTypesense.Connection.t(), String.t(), map(), keyword() ) :: {:ok, OpenApiTypesense.CollectionUpdateSchema.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
update_collection(%{api_key: 123, host: ...}, collectionName, body, opts)
update_collection(Connection.new(), collectionName, body, opts)
@spec upsert_alias(String.t(), map()) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.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.
Example
iex> body = %{"collection_name" => "companies"}
iex> OpenApiTypesense.Collections.upsert_alias("foo", body)
@spec upsert_alias( map() | OpenApiTypesense.Connection.t(), String.t(), map() | keyword() ) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
upsert_alias(%{api_key: 123, host: ...}, aliasName, body)
upsert_alias(Connection.new(), aliasName, body)
upsert_alias(aliasName, body, opts)
@spec upsert_alias( map() | OpenApiTypesense.Connection.t(), String.t(), map(), keyword() ) :: {:ok, OpenApiTypesense.CollectionAlias.t()} | {:error, OpenApiTypesense.ApiResponse.t()}
Either one of:
upsert_alias(%{api_key: 123, host: ...}, aliasName, body, opts)
upsert_alias(Connection.new(), aliasName, body, opts)