Copied to clipboard

Flag this post as spam?

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


  • Thanabalan 3 posts 23 karma points
    Apr 25, 2013 @ 10:11
    Thanabalan
    0

    Examine search for single word

    Hi i am using examine seach in my umbraco project, i have the following issue please help to fix it

    if i search letter "J" it should display the name starts with j only.

    but it searches like below


    Johnson

    Ball Jr.
    Wells Jr.

    Zochowski Jr

    I want search result only for

    Johnson

    My code is

     var searchCriteria = searcher.CreateSearchCriteria();
                IBooleanOperation filter = null;
                var words = s.Split(' ');
                var fields = new string[] { "lastName" }
                foreach (var word in words)
                {
                    if (filter == null)
                    {
                        filter = searchCriteria.GroupedOr(fields, word.MultipleCharacterWildcard());
                    }
                    else
                    {
                        filter = filter.And().GroupedOr(fields, word.MultipleCharacterWildcard());
                    }
                }
                foreach (string id in lawyersToExclude)
                {
                    filter = filter.Not().Field("id", id);
                }
                return filter;

     

     

Please Sign in or register to post replies

Write your reply to:

Draft