Muninn.Index (Muninn v0.5.5)
View SourceIndex management for Muninn search engine.
An index is a searchable collection of documents. Before creating an index, you must define a schema that describes the structure of your documents.
Example
# Create a schema
schema = Muninn.Schema.new()
|> Muninn.Schema.add_text_field("title", stored: true)
|> Muninn.Schema.add_text_field("body", stored: true)
# Create an index
{:ok, index} = Muninn.Index.create("/tmp/my_index", schema)
Summary
Functions
Creates a new index at the specified path with the given schema.
Opens an existing index at the specified path.
Types
@type t() :: reference()
Functions
@spec create(String.t(), Muninn.Schema.t()) :: {:ok, t()} | {:error, atom()}
Creates a new index at the specified path with the given schema.
The index directory will be created if it doesn't exist. If the directory already contains an index, an error will be returned.
Parameters
path- The directory path where the index will be storedschema- AMuninn.Schemadefining the index structure
Returns
{:ok, index}- Successfully created index{:error, reason}- Failed to create index
Examples
schema = Muninn.Schema.new()
|> Muninn.Schema.add_text_field("title", stored: true)
{:ok, index} = Muninn.Index.create("/tmp/my_index", schema)
Opens an existing index at the specified path.
Parameters
path- The directory path where the index is stored
Returns
{:ok, index}- Successfully opened index{:error, reason}- Failed to open index
Examples
{:ok, index} = Muninn.Index.open("/tmp/my_index")