Search K
Appearance
On this page we introduce all currently available search engines that implement ISearchEngine
.
The DatabaseSearchEngine
is included by default and accepts a list of columns that will be searched.
Database indexing
For performance reasons, we strongly recommend that you index all searchable database columns.
You can create your own implementation by defining a class that adheres to the ISearchEngine
interface. The TSearchable
is the entity type of the searchable resource. In your custom Search()
method you can modify the query for your own needs.
public class CustomSearchEngine<TSearchable> : ISearchEngine<TSearchable> where TSearchable : class
{
public IQueryable<TSearchable> Search(IQueryable<TSearchable> queryable, string searchQuery)
{
// Add custom conditions to the query to restrict the results
return queryable;
}
}
In our demo application, you will find an example for a custom search engine, that only returns internal employees of the company. This might be useful in scenarios where external employees are not managed in-house but are listed for organizational purposes.
public class InternalEmployeeSearchEngine<Employee> : ISearchEngine<TSearchable> where TSearchable : class
{
public IQueryable<Employee> Search(IQueryable<Employee> queryable, string searchQuery)
{
// Filter out external employees from search results
queryable.Where(e => e.IsExternal == false);
return queryable;
}
}