Copied to clipboard

Flag this post as spam?

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


  • ibrahim TUNC 55 posts 133 karma points
    Mar 04, 2019 @ 11:17
    ibrahim TUNC
    0

    Total duration (score) of search results

    How do I find the total duration of search results with the Razor syntax without calculating the time period for each item.

    Search.cshtml :

    @{ //Get the search term from query string var searchTerm = Request.QueryString["query"].ToString(); var searchCategory = Request.QueryString["category"].ToString();

                if (!string.IsNullOrEmpty(Request.QueryString["query"]) && !string.IsNullOrEmpty(Request.QueryString["category"]))
                {
                    var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["PeopleRepositoryhSearcher"];
                    var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.And);
    
                    var searchQuery = searchCriteria.Field("personName", searchTerm).And().Field("personCategories", searchCategory);
    
                    var searchResults = searcher.Search(searchQuery.Compile());
    
                    var scorer = searchQuery.Compile();
    
    
                    TempData["totalFoundResults"] = searchResults.Count();
                    //TempData["totalFoundResults"] = searchResults.TakeWhile(x => x.Score > 0.05f);
    
                    foreach (var item in searchResults)
                    {
                        IPublishedContent node = Umbraco.Content(item.Fields["id"]);
    
                        var nodeId = Umbraco.TypedContent(item.Id);
                        var mediaItem = Umbraco.TypedMedia(item.Fields["personPhoto"]);
    
                        <div class="col-lg-2 thumb">
                            <a href="@node.Url" title="" class="thumb-link">
                                <div class="thumb-info">
                                    <span class="thumb-info-wrapper">
    
                                        <img src="@mediaItem.GetCropUrl("thumbnail")" class="img-fluid" alt="" />
    
                                    </span>
                                    <div class="thumb-info-caption">
                                        <div class="thumb-info-caption-text">
                                            <h5 class="mb-1">@item.Fields["personName"] @item.Fields["personSurname"]</h5>
                                            @item.Fields["personPosition"]
                                        </div>
                                        <span>@item.Fields["personCategories"]</span>
                                    </div>
                                </div>
                            </a>
                        </div>
                    }
                }
    

    }

    Thank you.

Please Sign in or register to post replies

Write your reply to:

Draft