Copied to clipboard

Flag this post as spam?

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


  • Babajide 26 posts 46 karma points
    Aug 30, 2012 @ 21:36
    Babajide
    0

    Umbraco Examine cant search for input with two words

    Hello, my search works when an input like "testimonial" is searched for, but an input like "about us" returns 0 results. I've seen a forum post where people used "split" and "GroupedOr" but i cant get it to work in my code. Here's my code:

    public string Term getset}
        public int Count getset}

            protected void Page_Load(object senderEventArgs e)
            {
                
                if (!String.IsNullOrEmpty(Request.QueryString["s"]))
                {
                    Term Request.QueryString["s"].ToString();
                    
                    if (Term.Length 1)
                    {
                        
                        //Create search Criteria
                        var sc ExamineManager.Instance.CreateSearchCriteria();

                        //define query
                        var query sc.NodeName(Term.MultipleCharacterWildcard())
                        .Or()
                                    .Field("block1"Term.MultipleCharacterWildcard())
                        .Or()
                                    .Field("block2"Term.MultipleCharacterWildcard())
                        .Or()
                                    .Field("block3"Term.MultipleCharacterWildcard())
                        .Or()
                                    .Field("blockTitle1"Term.MultipleCharacterWildcard())
                        .Or()
                                    .Field("blockTitle2"Term.MultipleCharacterWildcard())
                        .Or()
                                    .Field("blockTitle3"Term.MultipleCharacterWildcard())
                        .Or()
                                    .Field("siteName"Term.MultipleCharacterWildcard());

                        //   .Or()
                        //   .Field("summary"Term.MultipleCharacterWildcard());

                        //or search by keyword

                        var results ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"].Search(Termtrue);
                        rp_results.DataSource results;
                        Count results.Count();
                        rp_results.DataBind();
                    }
                }
              
            }

     

    Thanks in advance.

     

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 31, 2012 @ 10:53
    Ismail Mayat
    0

    babajide,

    You need to do var terms = Term.split(' ');

    foreach(var t in terms){

    //use t as query input with Or

    }

     

    Regards


    Ismail

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 31, 2012 @ 11:34
    Ismail Mayat
    0

    Also why are you doing 

     

    var results ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"].Search(Termtrue);

     

    if should be 

     

    var results ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"].Search(query.Compile());

  • Funka! 398 posts 661 karma points
    Aug 31, 2012 @ 19:20
    Funka!
    0

    I wonder if this is the same problem I've noted with the admin backend UI search (you know, the thing in the top-left corner) where you only get results if you search for a single word, but never get any results if you include two or more. Hmmm....

Please Sign in or register to post replies

Write your reply to:

Draft