I am trying to get some search functionality working on a website and i was wondering why i am getting the below issue when following the documentation here:
My code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Examine.LuceneEngine.SearchCriteria;
@{
var query = "campaigns";
var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var searchCriteria = searcher.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or);
var searchQuery = searchCriteria.Field("nodeName", query.Boost(5)).Or().Field("nodeName", query.Fuzzy()).And().OrderByDescending("createDate");
var searchResults = searcher.Search(searchQuery.Compile());
if (searchResults.Any())
{
<ul>
@foreach (var result in searchResults)
{
<li>
<a href="@result.Url">@result.Name</a>
</li>
}
</ul>
}
}
That documentation looks to need a small tweak. To access the Url and Name attributes I'm guessing it's expecting to loop through an IEnumerable of IPublishedContent, so try changing to the following.
@foreach (var result in Umbraco.TypedContent(searchResults.Select(x=>x.Id)))
Fluent API - Following documentation errors
Hi,
I am trying to get some search functionality working on a website and i was wondering why i am getting the below issue when following the documentation here:
My code:
Thank you :)
Hi Gary,
That documentation looks to need a small tweak. To access the Url and Name attributes I'm guessing it's expecting to loop through an IEnumerable of IPublishedContent, so try changing to the following.
HTH, David
Thank you David :)
is working on a reply...