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

    I am on Modx 0.9.6.3 and AjaxSearch 1.8.1.

    I am trying to influence the ranking of search results for my company’s intranet site (sorry I can’t send a link). The search is working great for most terms but there are a few cases where there are many, many results and the pages that should be ranking highly are not. Also, I’ve tried to use FireBug to see what may be happening but I think I need help using that too.

    Here is the snippet call on my search results page:
    [!AjaxSearch? &ajaxSearch=`0` &AS_showForm=`0` &advSearch=`allwords` &order=`pagetitle ASC` &rank=`pagetitle:200,alias:10,extract` &extract=`1:pagetitle,content` &extractLength=`100` &highlightResult=`1` &grabMax=`6` &debug=`-3`!]


    Also, I have tried using the `exactphrase` parameter and it seems to make things worse.
    What I need to have happen is for longtitle or pagetitle to be heavily weighted in the ranking order and that just doesn’t appear to be working. Please help! Any advice is appreciated.

    Thanks.
      illegitimati non carborundum
      • 5811
      • 1,717 Posts
      Could you send by PM the address of your site in production and the search terms used to test the &rank parameter. Thanks.
        • 5811
        • 1,717 Posts
        Hi Julie,

        I think you got the same issue as [AJAXSEARCH-6] : Sort with order and ranking parameters. Results with a wrong order.

        In fact, the ranking couldn’t work with the non-ajax mode when the pagination occurs.
        With release 1.8.1, in the file classes/ajaxSearch.class.inc.php replace the lines:
                  // output results in searchResults array
                  $useLimit = ($this->cfg['grabMax'] > 0)? $this->offset + $this->cfg['grabMax'] : $nbrs;
                  for ($y = $this->offset; ($y < $useLimit) && ($y < $nbrs); $y++) {
                    $moveToRow = mysql_data_seek($rs,$y);
                    $row = $modx->db->getRow($rs);
                    $result = $this->addExtractToRow($row);
                    $this->searchResults[] = $result; 
                    if ($this->dbgRes) $this->asDebug->dbgLog($result,"AjaxSearchPopup - Output results before ranking");
                  }
        
                  // sort search results by rank if needed
                  $this->sortResultsByRank($this->searchString,$this->advSearch); 
        
        by
                  // output results in searchResults array
                  while ($row = mysql_fetch_assoc($rs)) {
                    $result = $this->addExtractToRow($row);
                    $this->searchResults[] = $result;
                    if ($this->dbgRes) $this->asDebug->dbgLog($result,"AjaxSearch - Output result before ranking");   // search results
                  }
        
                  // sort search results by rank if needed
                  $this->sortResultsByRank($this->searchString,$this->advSearch); 
                  // limit the search results to the current page
                  $length = ($this->cfg['grabMax'] > 0)? $this->cfg['grabMax'] : $nbrs;
                  $this->searchResults = array_slice($this->searchResults,$this->offset,$length);
        
        Or simply drop in the snippets/ajaxSearch/classes folder the attached file.

        The release 1.8.2 integrates this update. To compare the results between 1.8.1 (before fixing) and 1.8.2 try to search "education" on these demo pages and compare the results.

        1.8.1 version - With order and rank parameters

        1.8.2 version - With order and rank parameters

        Let me know if you have solved your issue.
          • 15022
          • 31 Posts
          Thank you! It looks like that solved the problem... I will do some more testing to make sure but it appears to be working as expected. This is great!
            illegitimati non carborundum