Full Text Search for Umbraco, is released in version 4.0.0 with a bunch of bugfixes, performance improvements, and some new languages. With great help from the community the package is now better than ever.
In this release there is 4 notable new features, that I will describe below. If you are interested, you can see the complete changelog.
Download Full Text Search on Umbraco Marketplace
Configure through appsettings.json
To improve DX, and make it a little bit easier to install, you can now configure FullTextSearch from your appsettings.json file. In addition to that, Full Text Search, will automatically "add it self" to your project. No more need for putting .AddFullTextSearch()
in your Startup.cs file.
You can configure Full Text Search like this in your appsettings.json file:
{
"Umbraco": {
"FullTextSearch": {
"DefaultTitleField": "searchResultTitle",
"DisallowedContentTypeAliases": [ "verySecretContent" ],
"DisallowedPropertyAliases": [ "hideInSearch" ],
"Enabled": true,
"FullTextPathField": "MyCustomPathField",
"FullTextContentField": "MyCustomContentField",
"HighlightPattern": "<span class=\"bold\">{0}</span>",
"RenderingActiveKey": "HiEverybody!",
"XPathsToRemove": [ "//script" ]
},
}
}
Full Text Search also now ships with an appsettings-schema.json file, so you'll get Intellisense when configuring through appsettings.json.
Pages are rendered using Http Client
Your pages are now being rendered using a Http Client, before being indexed by Full Text Search. This has the benefit, that route hijacked pages now actually works. Before, when we relied on Umbracos internal RenderTemplate
method, it wouldn't pass through any custom controllers, and thus not get assigned any custom view models.
Because of this, it's required that your webserver can "call it self", in order to fetch the content of the pages. Usually this is not a problem, but if you can't, and you have no way of allowing it, you can revert back to the old rendering method.
This is done by registering RazorPageRenderer
as the IPageRenderer
. This is usually done in a composer, or in your Startup.cs file, eg.:
public void ConfigureServices(IServiceCollection services)
{
// omitted...
services.AddUnique<IPageRenderer, RazorPageRenderer>();
}
Use Full Text Search to search non-content
Previously Full Text Search, would only let you search published content with a template defined in Umbraco. But sometimes you might want to leverage the search helpers, to search other content from Examine, eg. custom indexes and stuff that might not be Umbraco content at all.
When configuring the search query, you can now use SetIndex(string index)
to define which index to search (default is the default ExternalIndex in Umbraco), or SetSearcher(string searcher)
to define a custom searcher to use. This lets you search custom indexes instead of the default ExternalIndex.
To allow searching content that maybe isn't published, is Umbraco content, or doesn't have a template, you can use SetContentOnly(bool contentOnly)
, SetPublishedOnly(bool publishedOnly)
or SetRequireTemplate(bool requireTemplate)
. Or you could combine them all, by using SearchEverything()
, which will set the search to NOT content only, NOT published only, and no required template.
And if you need some special Lucene query in your search query, you can now add SetCustomQuery(string customQuery)
, which will add the defined customQuery
to your complete search query.
Listen for notifications when caching content
Full Text Search caches the rendered content of all pages, to make reindexing faster. Content gets cached everytime a node is published, to make sure to content is up to date.
We've now added notifications for this, so you can use Full Text Search, as a feeding mechanism for other providers, like Relewise, Algolia or others. The cache service sends a CacheSavingNotification
when it starts saving content to the cache. In here you can also modify the content being cached. And when the content is saved to the cache, it sends a CacheSavedNotification
, where you could hook in, and send the content to other providers too.
Thanks to all contributors
All this wouldn't have been possible without contributions from
Top comments (0)