Umbraco Multisearcher Examine example

Using Multisearcher Examine provider to searching across multiple indexes

Posted on Wednesday, April 12, 2017


I have blogged about using Examine to search your content in umbraco before , Search Umbraco using Examine and Razor; and there is good articles on setting up Examine available on the web - Rasmus Fjord 24days article is a good start, along with blog on Umbraco.com : Examining Examine and the documentation on Our Umbraco is good reference.

A common question appearing on twitter and the umbraco forums is how to search two or more indexes. 

It is fairly straight forward - using the provider in the Examine namespace (source code on Github )

I have created a project available over at bit bucket which demonstrates (in a simple example) searching both content items in the umbraco project and pdf media items (including text within the pdf using UmbracoExamine.PDF)

Steps

  • Setup content index (in this case ExternalIndexer) - you can see this working on it's own in the  'single-search' branch.
  • Setup pdf search index ( in this case PDFIndexer) - you can see this working in the 'PDFSearch' branch.
  • The final step was to introduce the MultiSearcher in the ExamineSettings.config :
 <add name="MultiSearcher" type="Examine.LuceneEngine.Providers.MultiIndexSearcher, Examine"
          analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true" indexSets="ExternalIndexSet,PDFIndexSet" />

 Code of search razor code shown below.

 

 Please note, a gotcha is that in Umbraco backoffice, within Examine Management, using the multisearcher 'Search Tools' no results will be displayed.