EctoTsvector.Migration (ecto_tsvector v0.1.0)

Add tsvector fields in Ecto migrations.

Summary

Functions

Adds a column of type :regconfig to a table containing the search language for a particular record, along with a tsvector column that targets a pre-existing field that is compatible with tsvector (the field argument). Creates a gin index on the vector and language fields for efficient search.

Functions

add_tsvector_search(table, field, opts \\ [])

(macro)

Adds a column of type :regconfig to a table containing the search language for a particular record, along with a tsvector column that targets a pre-existing field that is compatible with tsvector (the field argument). Creates a gin index on the vector and language fields for efficient search.

Options

* `:vector_field` - Name of the tsvector column, defaults to `:search_vector`.
* `:language_field` - Name of the regconfig language column, defaults to `:search_language`.
* `:default_language` - The default dictionary to replace null values, defaults to `"simple"`.

Examples

defmodule MyApp.Repo.Migrations.AlterMessagesAddTsvectorSearch do
  use Ecto.Migration

  import EctoTsvector.Migration

  def change do
    add_tsvector_search(:messages, :text, default_language: "english")
  end
end