Global Search Query#
Magql provides a
search query field that will perform a global search using
registered providers. Magql-SQLAlchemy registers a provider for each model that
will search all string columns.
The Query and Results#
search query field takes one argument,
value, the string to search for.
It returns a list of items.
The items in the list have the following keys:
type, the name of the model class.
id, the primary key of the row.
value, the string representation of the model row (
extra, currently unused, arbitrary extra information about the row.
id, a UI could present search results that link to that
Disabling for a Model#
ModelGroup.from_declarative_base, it takes a
argument to control what models are searchable.
True, which generates a search provider for ever
model. You can reassign
disable search for that model. If you set
False, no providers will
You can pass a set of model classes and/or model names to
generate providers only for those models.
Customizing a Provider#
The default search provider for each model is
which generates a
ILIKE query against all of the model’s string-like columns.