It's a distributed enterprise search solution.
Enterprise applications that are based on Microservices, are split into several small applications each with its own database, business rules and content. However, there is a need for the end-user to have a central place to run a search to find appropriate business data, regardless of where it's actually hosted.
Olive.GlobalSearch provides a solution to make that happen in the easiest way possible.
It consists of a UI component, where the user will type in some keywords to search. The search query will then be passed on to various individual micro-services via HTTP-based Apis. They will each then provide their own "participation", i.e. search results for the same keywords. The UI component will then show all results across all services in a single auto-complete list.
Each result item will have a Title (mandatory), Description, DestinationUrl (mandatory) and IconUrl. They can also provide a css style for the item so that they can be styled differently. For example depending on the type of the content item, it can be shown in a different colour in the auto-complete.
- Add an auto-complete control where in the template you want to show the textbox for search:
<input type="text" name="searcher" placeholder="Search..."
class="form-control global-search"
globalsearch-source="@(Url.ActionWithQuery("GlobalSearch/AutoComplete"))" />- Add the following controller action to your application in a new controller file.
[HttpGet, Route("GlobalSearch/AutoComplete")]
public async Task<ActionResult> GetServiceSource() =>
Json(Config.SettingsUnder("Olive.GlobalSearch:Sources").Select(x => x.Value).ToArray());- In
appSettings.jsonadd:
"Olive.GlobalSearch": {
"Sources": [
{ "My Site 1": "http://mysite1.com/api/global-search" },
{ "My Site 2": "http://mysite2.com/global-search.axd" },
...
]
}In each microservice that contributes to search results (perhaps including Access Hub itself) add the following:
Add the Olive.GlobalSearch.Source nuget package.
Add the following class to the Website project:
public class GlobalSearchSource : Olive.GlobalSearch.SearchSource
{
public override async Task Process(ClaimsPrincipal user)
{
// TODO: Process the keywords and add result items.
foreach (var something in await SomeThings...())
{
if (MatchesKeywords(something))
Add(new SearchResult { Url = "...", Title = "...", Description = "...", IconUrl = "..." });
}
if (user.IsInRole("Administrator"))
{
// Role specific results ...
}
}
}- In StartUp.cs, add:
public override void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
base.Configure(app, env);
...
app.UseGlobalSearch<GlobalSearchSource>();
...
}For legacy ASP.NET applications, add the following code to Web.config:
<configuration>
<system.webServer>
<handlers>
<add name="Olive Global Search" verb="GET" path="global-search.axd" type="GlobalSearchSource" />
</handlers>
<system.webServer>
</configuration>