Sifter.Options (Sifter v0.2.0)
View SourceResolved, runtime options that control Sifter's behavior.
Precedence (highest → lowest):
- Per-call overrides (opts to
Sifter.filter/3) - Per-process/request default (e.g., set by a Plug)
- 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
:tsquery_modedefaults to:plainto(usesplainto_tsquery)- When
:tsquery_modeis:plainto, defaults toSifter.FullText.Sanitizers.Basic - When
:tsquery_modeis:raw, defaults toSifter.FullText.Sanitizers.Strict
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
@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 }