A lightweight Typesense client for Elixir.
If available in Hex, the package can be installed
by adding typesense
to your list of dependencies in mix.exs
:
def deps do
[
{:typesense, "~> 0.2.0"}
]
end
# config/config.exs
config :typesense,
api_url: "https://search.example.com",
api_key: "secret"
To create a Typesense Collection:
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)
To index a Typesense Document:
document = %{
id: "124",
company_name: "Stark Industries",
num_employees: 5215,
country: "USA"
}
Typesense.Documents.create(collection, document)