In Config/ExamineIndex.config, you create a new IndexSet with all the properties you want users to be able to search for.
The Umbraco.TypedSearch(Request.QueryString["query"]); will search for anything throughout the page, but if you set up UmbracoExamine correctly, you can choose what Document Types you want people to be able to search for, as well as you can choose what kind of properties you want people to be able to index the content based on.
For example:
<IndexSet SetName="ExternalTopLevelSearchSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/{machinename}/TopLevelSearch/">
<IndexAttributeFields>
<add Name="Name"/>
<add Name="bodyText"/>
<add Name="tags"/>
<add Name="themes"/>
<add Name="parentID"/>
</IndexAttributeFields>
<IncludeNodeTypes>
<add Name="ArticlePage" />
</IncludeNodeTypes>
</IndexSet>
Then you have to create an Indexer in Config/ExamineSettings.config
<add name="ExternalTopLevelIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
supportUnpublished="false"
supportProtected="false"
interval="10"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"
indexSet="ExternalTopLevelSearchSet"/>
Now, you create a Search Provider, also in Config/ExamineSettings.config
<add name="ExternalTopLevelSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" indexSet="ExternalTopLevelSearchSet" enableLeadingWildcards="true"/>
Here's my C# code using the "ExternalTopLevel"-searcher shown above.
public List<SearchResult> SearchResults
{
get
{
if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["q"])) {
var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalTopLevelSearcher"];
// Search criteria.
var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
var q = HttpContext.Current.Request.QueryString["q"].ToLower().Trim().Split(' ');
var contentType = HelperClass.GetContentTypeNodes().FirstOrDefault(item => q.Contains(item.Name.ToLower()));
q = q.Where(i => i.Length > 3).ToArray();
var query = searchCriteria
.GroupedOr(new[] { "nodeName" }, q.Select(x => x.Boost(150)).ToArray())
.Or()
.GroupedOr(new[] { "grid" }, q.Select(x => x.Boost(80)).ToArray())
.Or()
.GroupedOr(new[] { "tags", "themes", "institutions" }, q.Select(x => x.Boost(110)).ToArray());
// Search results
var searchResults = searcher.Search(query.Compile()).OrderByDescending(x => x.Score);
return searchResults.ToList();
}
return new List<SearchResult>();
}
}
Hope this helps you out!