Copied to clipboard

Flag this post as spam?

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


  • Graham Carr 277 posts 389 karma points
    Mar 01, 2016 @ 16:08
    Graham Carr
    0

    Examine search help

    I am trying to convert the following LINQ query into an examine query instead:

    ms.GetMembersByMemberType("Candidate")
    .Where(x => x.IsApproved && x.GetValue("lastName").ToString().ToUpper().Substring(0,1) == dlLetters.SelectedValue)
    .OrderBy(candidate => candidate.GetValue("lastName"))
    

    I understand how to check for the IsApproved and the member type of candidate however I am not so sure on how to do the following in an Examine query:

    1. Search for last names that start with a chosen letter
    2. Order the results by last name

    Any help would be appreciated.

  • Veronica Burd 76 posts 201 karma points
    Mar 01, 2016 @ 17:37
    Veronica Burd
    0

    Hi,

    You could use a wildcard. The lucene syntax would be something like this:

    +lastName: X*

    where X would be replaced with the result of dlLetters.SelectedValue

    HTH,

    Ver

  • Graham Carr 277 posts 389 karma points
    Mar 02, 2016 @ 14:06
    Graham Carr
    0

    Hi,

    This doesn't seem to work. If I have the following examine query:

    var memberQuery = searchCriteria.Field("nodeTypeAlias", "Candidate")
    .And().Field("lastName", dlLetters.SelectedValue + "*")
    .And().Field("umbracoMemberApproved", "1")
    .Compile();
    

    and if for example the selected value in dropdown is B, when the search criteria is compiled it comes out as:

    +lastName:b

    So it converts the letter to lowercase and removes the * wildcard.

    Any ideas?

  • Graham Carr 277 posts 389 karma points
    Mar 02, 2016 @ 14:25
    Graham Carr
    0

    I have worked this out, I had to use

    dlLetters.SelectedValue.MultipleCharacterWildcard()
    

    for the wildcard criteria field value.

Please Sign in or register to post replies

Write your reply to:

Draft