View Source Haystack.Index.Field (Haystack v0.1.0)

A module for index fields.

This module allows you to configure the fields of the index. Each field can have a customised set of transformers and a custom regex used for tokenizing.

Link to this section Summary

Functions

Create a new field.

Create a new "term" field.

Link to this section Types

@type k() :: String.t()
@type t() :: %Haystack.Index.Field{
  k: k(),
  path: [String.t()],
  separator: Regex.t(),
  transformers: [module()]
}

Link to this section Functions

@spec new(k(), Keyword.t()) :: t()

Create a new field.

You can include nested fields using dot syntax. The field accepts an optional list of transformers to be used as well as a regex used for tokenizing.

examples

Examples

iex> field = Index.Field.new("name")
iex> field.k
"name"

iex> field = Index.Field.new("address.line_1")
iex> field.path
["address", "line_1"]
@spec term(k()) :: t()

Create a new "term" field.

A term field is a field that shouldn't be tokenized or transformed. For example, an ID, serial code, etc.

examples

Examples

iex> field = Index.Field.term("id")
iex> field.transformers
[]