Sifter.Options (Sifter v0.2.0)

View Source

Resolved, runtime options that control Sifter's behavior.

Precedence (highest → lowest):

  1. Per-call overrides (opts to Sifter.filter/3)
  2. Per-process/request default (e.g., set by a Plug)
  3. Application config (config :sifter, :options, ...)

Full-text Search Sanitization

Sifter provides pluggable sanitization for full-text search terms with two built-in sanitizers and support for custom sanitization functions.

Default Behavior

Configuration Examples

# Application-wide defaults
config :sifter, :options,
  tsquery_mode: :raw,
  full_text_sanitizer: &MyApp.CustomSanitizer.sanitize/1

# Per-call override
Sifter.filter!(Entry, query,
  schema: Entry,
  search_fields: :searchable,
  search_strategy: {:column, {"english", :searchable}},
  tsquery_mode: :raw,
  full_text_sanitizer: {MyApp.Sanitizer, :custom_sanitize, []}
)

Summary

Functions

Resolve final options from app config, process default, and per-call overrides.

Types

t()

@type t() :: %Sifter.Options{
  empty_in: false | true | :error,
  full_text_sanitizer:
    (String.t() -> String.t()) | {module(), atom(), list()} | nil,
  invalid_cast: :ignore | :warn | :error,
  join_overflow: :ignore | :error,
  max_joins: non_neg_integer(),
  tsquery_mode: :plainto | :raw,
  unknown_assoc: :ignore | :warn | :error,
  unknown_field: :ignore | :warn | :error,
  unsupported_op: :warn | :error
}

Functions

from_keyword(kw)

merge(base, kw)

mode(atom)

resolve(call_opts \\ [])

Resolve final options from app config, process default, and per-call overrides.

Recognizes :mode (:lenient | :strict) and individual knobs.