Copied to clipboard

Flag this post as spam?

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


  • Matt 308 posts 730 karma points
    Apr 08, 2020 @ 08:49
    Matt
    0

    Search showing no results

    Hi all,

    I'm having issues with my search, for some reason when I search I get no results.....

    Even tho when I search in back office I get results......

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Search>
    @using ContentModels = Umbraco.Web.PublishedModels;
    @using Umbraco.Examine
    @{
        Layout = "master.cshtml";
    var searchQuery = Request.QueryString["q"];
    
    }
    
    <div class="contact-clean">
        <form action="@Model.Url" method="GET" id="search">
            <div class="form-group">
                <div class="row">
                    <div class="col-xs-12 col-sm-8">
                        <input type="text" class="form-control col-xs-6" placeholder="Search..." name="q" value="@searchQuery" />
                    </div>
                    <div class="col-xs-12 col-sm-4">
                        <button class="btn btn-primary">Search <i class="fa fa-search"></i></button>
                    </div>
                    <div class="col-xs-12">
                        @if (!string.IsNullOrWhiteSpace(searchQuery))
                        {
                            var results = Umbraco.ContentQuery.Search(searchQuery, string.Empty);
                            long resultCount = results != null && results.Any() ? results.Count() : 0;
                            <div class="searchresults">
                                <p>We found <strong>@resultCount</strong> result@(resultCount != 1 ? "s" : "") when searching for <strong>@searchQuery</strong></p>
                                @if (resultCount > 0)
                                {
                                    <ul>
                                        @foreach (var result in results)
                                        {
                                            <li>
                                                <h3><a href="@result.Content.Url">@result.Content.Name</a></h3>
                                                <p>@(result.Content.Value<string>("metaDescription"))</p>
                                            </li>
                                        }
                                    </ul>
                                }
                            </div>
                        }
                    </div>
                </div>
            </div>
        </form>
    </div>
    

    Scratching head

    I've also rebuilt my search index but no joy

    Thanks

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Apr 09, 2020 @ 22:05
    Alex Skrypnyk
    0

    Hi Matt

    What if you do a search in Umbraco developers section => examine indexes

    Does it work there?

  • Matt 308 posts 730 karma points
    Apr 09, 2020 @ 22:07
    Matt
    0

    Hi,

    Yeap I get the results......

    I just cant see anything wrong with the code which was from Pauls demo site.

  • Matt 308 posts 730 karma points
    Apr 17, 2020 @ 10:19
    Matt
    0

    Any other suggestions? :)

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Apr 17, 2020 @ 12:07
    Alex Skrypnyk
    0

    I just checked the Paul's demo on my machine and search works great.

  • Matt 308 posts 730 karma points
    Apr 17, 2020 @ 12:17
    Matt
    0

    Hmm its weird, I just deleted all my content and re-imported with uSync and it works fine now....

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies