Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Gary 80 posts 377 karma points
    Jul 15, 2019 @ 08:16

    Fluent API - Following documentation errors


    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:

    enter image description 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())
                @foreach (var result in searchResults)
                        <a href="@result.Url">@result.Name</a>

    Thank you :)

  • David Challener 80 posts 444 karma points c-trib
    Jul 15, 2019 @ 15:07
    David Challener

    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.

    @foreach (var result in Umbraco.TypedContent(searchResults.Select(x=>x.Id)))

    HTH, David

  • Gary 80 posts 377 karma points
    Jul 23, 2019 @ 08:18

    Thank you David :)

Please Sign in or register to post replies

Write your reply to: