Something Shannon and I had discussed a few times was that we wanted to decouple Examine from Umbraco so it could be used for indexing on sites other than Umbraco.
You’ll also notice that I keep referring to it as Examine, not Umbraco Examine which most people are more familiar with.
This is because over the last week we have achieved what we’d wanted to do, we’ve decoupled Examine from Umbraco!
So what’s Examine?
Examine is a provider based, config driven search and indexer framework. Examine provides all the methods required for indexing and searching any data source you want to use.
Examine is now agnostic of the indexer/ searcher API, as well as the data source. That’s right Examine has no references within itself to Umbraco, nor does it have any references to Lucene.NET.
We have still maintained a usage of XML internally for passing the data-to-index around, as it’s the easiest construct which we could think to work with and pass around.
You could implement the Examine framework in any solution, to index any data you want, it could be from a SQL server, or it could be from web-scraped content.
Where does that leave Umbraco Examine?
Umbraco Examine still exists, in fact it’s the primary (and currently only) implementer of Examine. Over the last week though we’ve done a lot of refactoring of Umbraco Examine to work with some changes we’ve done to the underlying Examine API.
Changes? What changes?
Last week anyone who follows me on Twitter will have seen a lot of tweets around Umbraco Examine which was about a new search API and the breaking changes we were implementing.
While looking to refactor the underlying API of a large Umbraco site we have running I found that Examine was actually not properly designed if you wanted to search for data in specific fields, or build complex search queries.
This was a real bugger, I had many different parameters I needed to optionally search on, and only in certain fields, but since Umbraco Examine works with just a raw string this wasn’t possible.
So I set about creating a new fluent search API. This has actually turned out quite well, in fact so well that we new have this as the recommended search method, not raw text (which is still available).
The fluent API is part of the Examine API so it’s also available for any implementation, not just Umbraco! Since we’ve used Lucene.NET as the initial support model the API is designed similarly to what you’d expect from Lucene.NET, but we hope that it’s generic enough to look and feel right for any indexer/ searcher.
Here’s how the fluent API looks:
searchCriteria .Id(1080) .Or() .Field("headerText", "umb".Fuzzy()) .And() .NodeTypeAlias("cws".MultipleCharacterWildcard()) .Not() .NodeName("home");
All you have to do is pass that into your searcher. That easy, and that beautiful. I’ll do a blog post where we’ll look more deeply into the fluent API separately.
Additionally we’ve done some other changes, because of what the framework new is we’ve renamed our assemblies and namespaces:
- This was formally UmbracoExamine.Core.dll
- Root namespace Examine
- Contains all the classes and methods to create your own indexer and searcher
- This was formally UmbracoExamine.Providers.dll
- Root namespace UmbracoExamine.dll
- Contains all the classes and methods of an Umbraco & Lucene.NET
Apologies to any existing implementations of Umbraco Examine, this will result in breaking changes but since we’ve not hit RC yet too bad :P.
There are also some changes to the config, <IndexUserFields /> has become <IndexStandardFields />, and obviously the config registrations are different with the assembly and namspace changes.
Currently we’re working to tidy up the API and the documentation so that we can get the RC release out shortly, so watch this space.