Copied to clipboard

Flag this post as spam?

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


  • Arun 6 posts 36 karma points
    Feb 03, 2014 @ 13:12
    Arun
    0

    Examine Search with a single character.

    I using examine for searching with a single character.Means I have a property named Firstname in my node and I have more than 100 nodes in my umbraco ,I trying to search all first name start with A and disply,so I using examine to impliment this.But it dosn''t return the values.here is my code.Can anyone help?.

     var contentSearcher = ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"];
        var searchCriteria = contentSearcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content, BooleanOperation.And);
    
        List<SearchResult> contentResults = new List<SearchResult>();
        string keyword = "";
    
         string[] contentSearchFields = {"firstName"};
               keyword = "A";
    
        var luceneString = "";
    
        if ((!string.IsNullOrEmpty(Request.QueryString["keyword"])))
        {
    
            if (!string.IsNullOrEmpty(keyword))
            {
                var keyWordQuery = "";
                string finalKeywordQuery = " +({0})";
                keyWordQuery += "lastName:" + keyword + "~0.3 ";
    
    
                luceneString += string.Format(finalKeywordQuery, keyWordQuery);
                luceneString += "+umbracoNaviHide:0";
            }
    
        var fquery = searchCriteria.RawQuery(luceneString);
        contentResults = contentSearcher.Search(fquery).ToList();
    

    var results = contentResults;

     

     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Feb 03, 2014 @ 15:09
    Ismail Mayat
    100

    Arun,

    The first letter search needs to be wildcard and not fuzzy so it should keyword +"*" get rid of the fuzzy bit. Also any reason why you are not using the fluent api?

    Regards

    Ismail

  • Arun 6 posts 36 karma points
    Feb 04, 2014 @ 04:46
    Arun
    0

    Thanks Ismail.It is worked.I using raw query because,here I have some complex searching criterias,Raw query helps a lot,so... :)

Please Sign in or register to post replies

Write your reply to:

Draft