Khafra.SearchBehaviour behaviour (khafra_search v0.3.3)

A behaviour for mapping Ecto schemas to Manticore Search RT tables.

Column definitions

index_fields/0 returns a list of column definitions. Each entry can be:

  • atom() — field name, Manticore type auto-detected from the Ecto schema
  • {atom(), :field | :attribute} — explicit column role
  • {atom(), :field | :attribute, keyword()} — role with column-level options

Roles

  • :field — full-text searchable (Manticore text column)
  • :attribute — stored for filtering, sorting, and grouping (Manticore string, uint, bigint, etc.)

For non-string Ecto types (integer, float, boolean, …) the Manticore type is always a numeric/boolean attribute regardless of the declared role.

Column options

  • stored: true — retain original text for retrieval (text fields only)
  • type: :bigint — override the auto-detected Manticore type

Table options

Optionally implement table_options/0 to declare table-level Manticore settings such as morphology, html_strip, stopwords, etc.

Link to this section Summary

Callbacks

A list of columns to index, as bare names or rich definitions

Table-level Manticore settings (morphology, stopwords, etc.)

Link to this section Types

Link to this type

column_def()

Specs

column_def() ::
  atom() | {atom(), column_role()} | {atom(), column_role(), [column_opt()]}
Link to this type

column_opt()

Specs

column_opt() :: {:stored, boolean()} | {:type, atom()}
Link to this type

column_role()

Specs

column_role() :: :field | :attribute

Link to this section Callbacks

Specs

index_fields() :: [column_def()]

A list of columns to index, as bare names or rich definitions

Link to this callback

table_options()

(optional)

Specs

table_options() :: keyword()

Table-level Manticore settings (morphology, stopwords, etc.)