Example payload
Search rules
The search rules object are a set of instructions defining search parameters Meilisearch will enforced in every query made with a specific tenant token.Search rules object
searchRules
must be a JSON object. Each key must correspond to one or more indexes:
filter
key. This filter
’s value must be a filter expression:
searchRules
object.
A token may contain rules for any number of indexes. Specific rulesets take precedence and overwrite *
rules.
Because tenant tokens are generated in your application, Meilisearch cannot check if search rule filters are valid. Invalid search rules return throw errors when searching.Consult the search API reference for more information on Meilisearch filter syntax.
Examples
Single filter
In this example, the user will only receivemedical_records
documents whose user_id
equals 1
:
Multiple filters
In this example, the user will only receivemedical_records
documents whose user_id
equals 1
and whose published
field equals true
:
Give access to all documents in an index
In this example, the user has access to all documents inmedical_records
:
Target multiple indexes with a partial wildcard
In this example, the user will receive documents from any index starting withmedical
. This includes indexes such as medical_records
and medical_patents
:
Target all indexes with a wildcard
In this example, the user will receive documents from any index in the whole instance:Target multiple indexes manually
In this example, the user has access to documents withuser_id = 1
for all indexes, except one. When querying medical_records
, the user will only have access to published documents:
API key UID
Tenant token payloads must include an API key UID to validate requests. The UID is an alphanumeric string identifying an API key:If an API key expires, any tenant tokens created with it will become invalid. The same applies if the API key is deleted or regenerated due to a changed master key.
Expiry date
The expiry date must be a UNIX timestamp ornull
:
The only way to revoke a token without an expiry date is to delete its parent API key.Changing an instance’s master key forces Meilisearch to regenerate all API keys and will also render all existing tenant tokens invalid.