Search K
Appearance
Resources can be made searchable by overriding the method GetSearchEngine()
in a resource and configuring the fields that should be included during a search.
We currently support the following fields for searching:
Here's an example from our demo application for an employee resource, and how to enable a database search for employees by email.
public class EmployeeResource : Resource<ApplicationDbContext, Employee, int>
{
public EmployeeResource(ApplicationDbContext context) : base(context){}
protected override ISearchEngine<Employee>? GetSearchEngine()
{
return new DatabaseSearchEngine<Employee>(["Email"]);
}
public override IList<IResourceFieldBuilder> Fields()
{
return
[
EmailField.Make("Email", nameof(Employee.Email)
.AsDisplayName(),
];
}
}
Whenever a resource has a search engine registered, a search field will appear above the entity table. Search fields will also appear in associated HasMany
tables, if the underlying resource has a search engine configured.
Every registered search engine is taken into account for a global search. This provides a convenient way for users to quickly search across all searchable resources. Results will be tagged with their associated resource.