We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2740
    • 95 Posts
    Hello,

    In the list of displayed results some contain only the page title with no extract yet others do. I’m using AS V1.90 and my AS call is:

    [!AjaxSearch? &ajaxSearch=`0` &debug=`-2` &asLog=`2:0:0` &showPagingAlways=`1` &tplInput=`as_advanced` &whereSearch=`content:content,longtitle` &grabMax=`10` &extractLength=`180` !]


    This is very odd, has anyone any suggestion?
      • 5811
      • 1,717 Posts
      by default &extract [int : Comma separated list of displayable fields | ’1:content,description,introtext,tv_value]

      in "Reminiscences of Ernest Bell" page, the content doesn’t contain "Ernest Bell"

      in "animal world tribute" page, the page doesn’t containt "Ernest Bell" but "Ernest Bell,"
      [EDIT]As you you use the exact phrase, it doesn’t found it.In fact, as a comma is not a word, the term should be found.


      in "Ernest Bell" page, you get the same effect with "<p>Ernest Bell was a long-time friend of Henry Salt, ..."
      [EDIT]The search term "Ernest Bell" doesn’t exist. Just "<p>Ernest Bell".In fact, as ">" is not a word, the term should be found.

      And then same thing with "hear of the death of Mr. Ernest Bell, so well-known for his humane work for animals."
      [EDIT]The search term "Ernest Bell" doesn’t exist. Just "Ernest Bell,".

      Keep in mind that the "exact phrase" option allow to search "bell" without getting extracts with "rebellious", "belligerent", "belladonna" ...
        • 2740
        • 95 Posts
        I assumed because it listed the term in the results that it also would give an extract in the results.

        Thanks coroico for clarifying, much appreciated.

          • 5811
          • 1,717 Posts
          I assumed because it listed the term in the results that it also would give an extract in the results.
          And you are right !

          By using &whereSearch=`content:content,longtitle` the search should occur only in these fields of the content table.
          As the longtitle doesn’t contain the search term, that means that the MYSQL request found the search term in the content field. But in the php script, when I try to search this term to set up the extract, I don’t found it (unless if this term is inside a html tag like <img src="">).

          If it is possible for you could, you send me, by personal message, the content of the document named "animal world tribute" and run a search (exact phrase with "ernest bell") with &debug=`3` and send me the ajaxSearch/debug/ajaxSearch_log.txt file. Thanks.

          Otherwise this is a very interesting site.
            • 5811
            • 1,717 Posts
            The search runs with the exact phrase is:
            SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.template, sc.menutitle, sc.content, sc.publishedon 
            FROM `modx_site_content` sc 
            WHERE ((sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.privateweb=0)) 
            GROUP BY sc.id 
            HAVING (((sc.content REGEXP '[[:<:]]Ernest Bell[[:>:]]') OR (sc.longtitle REGEXP '[[:<:]]Ernest Bell[[:>:]]'))) 


            The exact phrase use the clause: sc.content REGEXP ’[[:<:]]Ernest Bell[[:>:]]’
            As explained on this page:
            [[:<:]], [[:>:]]

            These markers stand for word boundaries. They match the beginning and end of words, respectively. A word is a sequence of word characters that is not preceded by or followed by word characters. A word character is an alphanumeric character in the alnum class or an underscore (_).
            So, in the extract "to hear of the death of Mr. Ernest Bell, so well-known for his humane work for animals", the term "ernest bell" is found as "Ernest Bell," because the comma is not considering as a word. Which is correct

            But unfortunately when I set up the result, I use " ernest bell " (surrounded with a space character!) as search term so I can’t find "ernest bell" in the sentence: "to hear of the death of Mr. Ernest Bell, so well-known for his humane work for animals"

            This issue is now registered as AJAXSEARCH-72. To fix this issue do as follow:

            1/ replace the line 168 of ajaxSearch/classes/ajaxSearchCtrl.class.php :
                    if ($advSearch == EXACTPHRASE) $searchList[] =  " " . $search . " ";
            by
                    if ($advSearch == EXACTPHRASE) $searchList[] =  $search;



            2/ replace the line 533 of ajaxSearch/classes/ajaxSearchResults.class.php :
                            $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
            by
                           if ($advSearch == EXACTPHRASE) $pattern = '/\b' . preg_quote($searchTerm, '/') . '\b/' . $pcreModifier;
                            else $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;


            3/ replace the line 595 of ajaxSearch/classes/ajaxSearchResults.class.php :
                            $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
            by
                            if ($advSearch == EXACTPHRASE) $pattern = '/\b' . preg_quote($searchTerm, '/') . '\b/' . $pcreModifier;
                            else $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;


            4/ replace the line 884 of ajaxSearch/classes/ajaxSearchResults.class.php :
                                    $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;
            by:
                                    if ($advSearch == EXACTPHRASE) $pattern = '/\b' . preg_quote($searchTerm, '/') . '\b/' . $pcreModifier;
                                    else $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;


            Thanks for this feedback.
              • 2740
              • 95 Posts
              I’ve made the changes recommended except to line 884 of ajaxSearchResults.class.inc.php as

              $pattern = '/' . preg_quote($searchTerm, '/') . '/' . $pcreModifier;


              doesn’t exist there or anywhere close by.

              The search results are now producing extracts for all results where the term is in the content.

              Thanks coroico, this is great.
                • 5811
                • 1,717 Posts
                I’ve made the changes recommended except to line 884 of ajaxSearchResults.class.inc.php as ... doesn’t exist there or anywhere close by.
                Apolgizes You can’t find these lines because they are added to fix the issue AJAXSEARCH-67 (mainly when you use Php <5.2). See: http://modxcms.com/forums/index.php/topic,50379.msg293387.html#msg293387.