Copied to clipboard

Flag this post as spam?

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


  • Sean Dooley 273 posts 490 karma points
    Oct 20, 2011 @ 15:21
    Sean Dooley
    0

    Using Examine with multiple search parameters

    I am looking to pass in multiple parameters to an examine search setup via ExamineSettings and ExamineIndex.

    Below is the Razor script that is invoking the examine search. How can this be amended to include multiple search parameters?

    @using Examine
    @using Examine.SearchCriteria
    @using UmbracoExamine
    @{
    var rootNode = @Model;
    var searchString = Request.QueryString["searchstring"];
    var firstparameter = Request.QueryString["cpr"];
    var secondParameter = Request.QueryString["wt"];

    var searchProvider = ExamineManager.Instance.SearchProviderCollection["SiteSearcher"];
    var searchCriteria = searchProvider.CreateSearchCriteria(BooleanOperation.Or);
    var query = searchCriteria.RawQuery(searchString);
    var searchResults = searchProvider.Search(query).OrderByDescending(x => x.Score);
    <section>
    <article>
    @if(searchResults.Count() > 0){
    <p>@searchResults.Count() results found for @searchString</p>
    <ul>
    @foreach (var c in searchResults){
    <li>
    <a href="@umbraco.library.NiceUrl(c.Id)">@c.Fields["nodeName"]</a>
    </li>
    }
    </ul>
    } else { <p>No results found.</p> }
    </article>
    </section>
    }
  • 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