Search Kit - Query Building with APIv4¶
Entities¶
Any APIv4 entity can be made available to SearchKit. Even nontraditional entities that do not
correspond to a SQL table will work as long as they have a get
action.
Whether an entity appears in SearchKit depends on the @searchable
annotation at the top of the API entity class
(if not present the entity defaults to "secondary"):
@searchable primary
: Appears at top of main entity list in SearchKit.@searchable secondary
(default): Appears in "Other" section at bottom of entity list.@searchable bridge
: Does not appear in entity list but SearchKit will use it to join other entities together.@searchable none
: Does not appear anywhere in SearchKit.
Joins¶
SearchKit automatically builds a list of entities that can be joined, based on foreign-keys from the schema. When the user selects a join in the admin UI, the criteria for linking those entities is invisibly added.
Option Lists¶
APIv4 supports a syntax for resolving option lists based on suffixes, for example selecting activity_type_id:label
will return "Meeting" instead of the id 1
. The SearchKit UI invisibly adds the :label
suffix to every field with an option list
so that results are returned formatted for display.
The SearchDisplay::run
API¶
SearchDisplay results are loaded indirectly via the SearchDisplay::run
API. This gives SearchKit more control of the
permission model, and the chance to add filters.