View Source Haystack.Index (Haystack v0.1.0)
A module for managing indexes.
The index is used to manage configuration and acts as a central point to add, update, delete, or query the storage.
Link to this section Summary
Functions
Add documents to the index.
Set the attrs of the index.
Delete documents in the index.
Add a field to the index.
Create a new index.
Add a ref to the index.
Search the index.
Set the storage on the index.
Link to this section Types
@type fields() :: %{required(Haystack.Index.Field.k()) => Haystack.Index.Field.t()}
@type opts() :: Keyword.t()
@type t() :: %Haystack.Index{ attrs: attrs(), fields: fields(), name: atom(), ref: Haystack.Index.Field.t(), storage: struct() }
Link to this section Functions
Add documents to the index.
examples
Examples
iex> index = Index.new(:animals)
iex> Index.add(index, [])
Set the attrs of the index.
examples
Examples
iex> index = Index.new(:animals)
iex> Index.attrs(index, %{insert: [Global], delete: [Global]})
Delete documents in the index.
examples
Examples
iex> index = Index.new(:animals)
iex> Index.delete(index, [])
@spec field(t(), Haystack.Index.Field.t()) :: t()
Add a field to the index.
examples
Examples
iex> index = Index.new(:animals)
iex> Index.field(index, Index.Field.new("name"))
Create a new index.
examples
Examples
iex> Index.new(:animals)
@spec ref(t(), Haystack.Index.Field.t()) :: t()
Add a ref to the index.
examples
Examples
iex> index = Index.new(:animals)
iex> Index.ref(index, Index.Field.new("id"))
Search the index.
Set the storage on the index.
examples
Examples
iex> index = Index.new(:animals)
iex> Index.storage(index, Storage.Map.new())