Copied to clipboard

Flag this post as spam?

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


  • kows 81 posts 151 karma points c-trib
    Oct 26, 2010 @ 11:27
    kows
    0

    Examine search every word

    <code>

                var criteria = ExamineManager.Instance
                    .SearchProviderCollection["DemoSearcher"]
                    .CreateSearchCriteria();
               
                string[] sSearchTerm = SearchTerm.Split(' ');

    Examine.SearchCriteria.IBooleanOperation filter = null;
                  for(int i = 0;i<sSearchTerm.Length;i++)
                    {
                      if(i==0){
                          filter = criteria.GroupedOr(new string[] { "nodeName", "bodyText" }, sSearchTerm[i])
                              .Not().Field("umbracoNaviHide", "1");
                      }else{
                          filter = filter.Or().GroupedOr(new string[] { "nodeName", "bodyText" }, sSearchTerm[i]);
                      }
                  }

                SearchResults =
                    ExamineManager.Instance.SearchProviderCollection["DemoSearcher"].Search(filter.Compile());

    </code>

    Hi,

    above is my code. I'm trying to search the nodeName & bodyText for each word in the inputted searchterm. Though it seems Examine only searches the first word i enter. I saw a similar topic with this but the only difference i saw was the way he split his SearchTerm. Tried quite some stuff already, hopefully you can give me some directions.

    greetings,

    Jonas

     

  • kows 81 posts 151 karma points c-trib
    Oct 26, 2010 @ 14:19
    kows
    0

     

               SearchResults =
                    ExamineManager.Instance.SearchProviderCollection["DemoSearcher"].Search(criteria.RawQuery("(nodeName:\"then\" OR bodyText:\"then\") OR (nodeName:\"go further\" OR bodyText:\"go further\") OR (nodeName:\"go\" OR bodyText:\"go\")"));

     

    temporarily solution for me, thought i would like the solution by using the IQuery stuff.

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 27, 2010 @ 00:35
    Aaron Powell
    0

    If  you do a ToString on the compiled filter what is the output?

  • kows 81 posts 151 karma points c-trib
    Oct 27, 2010 @ 10:14
    kows
    0

    { SearchIndexType: , LuceneQuery: +(nodeName:go bodyText:go) -umbracoNaviHide:1 (nodeName:further bodyText:further) }

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 27, 2010 @ 11:46
    Aaron Powell
    0

    The problem is that the 2nd query you're adding is added as an OR, but because the first one is an AND it will always take precidence.

    Check out the blog I did here: http://farmcode.org/post/2010/08/12/How-to-build-a-search-query-in-Examine.aspx it explains how queries are built in Examine.

Please Sign in or register to post replies

Write your reply to:

Draft