Command builders for RediSearch (FT.*) full-text search and indexing.
Provides pure functions for creating and managing search indexes, running full-text and numeric queries, performing aggregations, and managing auto-complete suggestion dictionaries. Includes a schema builder DSL that translates Elixir tuples into the FT.CREATE SCHEMA syntax.
All functions return command lists for use with Redis.command/2 or
Redis.pipeline/2.
Examples
# Create a JSON index with text, numeric, and tag fields
Redis.command(conn, Search.create("idx:users", :json,
prefix: "user:",
schema: [
{"$.name", :text, as: "name"},
{"$.age", :numeric, as: "age", sortable: true},
{"$.email", :tag, as: "email"}
]
))
# Full-text search with sorting and pagination
Redis.command(conn, Search.search("idx:users", "@name:Alice",
sortby: {"age", :asc},
limit: {0, 20},
return: ["name", "age"]
))
# Aggregation with grouping and reduction
Redis.command(conn, Search.aggregate("idx:users", "*",
groupby: ["@age"],
reduce: [{"COUNT", 0, as: "count"}],
sortby: [{"@count", :desc}],
limit: {0, 10}
))
Summary
Functions
FT.AGGREGATE — run an aggregation query.
FT.ALTER — add a field to an existing index.
FT.CREATE — create a search index.
FT.DROPINDEX — drop an index.
FT.INFO — get index information.
FT._LIST — list all indexes.
FT.SEARCH — search an index.
FT.SUGADD — add a suggestion string.
FT.SUGDEL — delete a suggestion.
FT.SUGGET — get suggestion strings.
FT.SUGLEN — get number of suggestions.
FT.TAGVALS — get all distinct tag values for a field.
Functions
FT.AGGREGATE — run an aggregation query.
Options
:groupby- list of fields to group by:reduce- list of reduce functions{func, nargs}or{func, nargs, as: alias}:sortby-[{field, :asc | :desc}]:limit-{offset, count}:apply-{expression, as: alias}:filter- filter expression:params-[{name, value}]:dialect- query dialect version
FT.ALTER — add a field to an existing index.
FT.CREATE — create a search index.
Options
:prefix- key prefix(es) to index (string or list):filter- filter expression:language- default language:score- default score:stopwords- list of stopwords (or 0 for none):schema- list of field definitions (required)
Schema Fields
Each field is a tuple: {name_or_path, type} or {name_or_path, type, opts}
Types: :text, :tag, :numeric, :geo, :vector
Field options:
:as- alias name:sortable- enable sorting:noindex- store but don't index:nostem- disable stemming (text):weight- field weight (text):separator- tag separator (default ",")
FT.DROPINDEX — drop an index.
FT.INFO — get index information.
@spec list() :: [String.t()]
FT._LIST — list all indexes.
FT.SEARCH — search an index.
Options
:return- list of fields to return:limit-{offset, count}(default:{0, 10}):sortby-{field, :asc | :desc}:nocontent- return only IDs:verbatim- don't expand query terms:params-[{name, value}]for parameterized queries:dialect- query dialect version
FT.SUGADD — add a suggestion string.
FT.SUGDEL — delete a suggestion.
FT.SUGGET — get suggestion strings.
FT.SUGLEN — get number of suggestions.
FT.TAGVALS — get all distinct tag values for a field.