We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5811
    • 1,717 Posts
    Thanks for this new feedback. I have added two new issues in the ajaxSearch bug tracker and updated my todo list tongue

    - http://svn.modxcms.com/jira/browse/ADDON-13" target="_blank" rel="nofollow"> ADDON-13 - AjaxSearch case insensitive highlighting

    [EDIT : See http://modxcms.com/forums/index.php/topic,28915.msg175565.html#msg175565 for a correction]

    - ADDON-10 - order and ranking don’t work together

    [EDIT : See http://modxcms.com/forums/index.php/topic,28845.msg175836.html#msg175836 for a correction]
      • 5811
      • 1,717 Posts
      FS#46 issue : order and ranking don’t work together

      This issue was a bit tricky to solve, but after a brain shaking, here is the solution.

      In the file classes/search.inc.php, replace the following code lines 498 to 502 :
            // sort the results by rank
            foreach($this->searchResults as $key => $row) {
              $rank[$key] = $row['rank'];
            }
            array_multisort($rank,SORT_DESC,$this->searchResults);
      by these code lines :
            // sort the results by rank
            $i = 0;
            foreach($this->searchResults as $key => $row) {
              $rank[$key] = $row['rank'];
              $ascOrder[$key] = $i++;
            }
            array_multisort($rank, SORT_DESC, $ascOrder, SORT_ASC, $this->searchResults);
          
      With this correction the rank parameter don’t break the sort get with &order.
      Tested on my local environment. This correction will be ported to the version 1.8.1

        • 24495
        • 407 Posts
        Thanks for the rapid fixing, FS#45 works perfect!

        But I think I don’t understand the ranking algorithm. Now I tried
        &order=`publishedon DESC` &rank=`pagetitle:100,extract`
        &order=`publishedon DESC` &rank=`pagetitle:100,longtitle:100,alias:100,extract`
        &order=`publishedon DESC` &rank=`pagetitle:100,longtitle:100,alias:100,extract:0`

        For all versions the results are same pages in same order.

        For my travel pages I think that visitors search first for travel targets. Most pages in this site are travel offers (about 70). About 10 further pages are common (contact, information, insurance, terms and conditions, ...).
        Main targets are written in pagetitle, longtitle and alias.

        If I set rank to "pagetitle:100,extract" and search for "Rom" I think I should get first the 3 existing Rom documents.
        First search result is a Rom target page. After that I get 9 results with other targets containing "rom" in extract (1 time), mostly inside other words "pROMenade, ROMantisch, ...). Results 11 and 12 are the other Rom pages. Why this and is it possible to adapt the ranking to get first the 3 pages containing "Rom" in pagetitle, longtitle AND alias?
          • 5811
          • 1,717 Posts
          Hi Rasc,

          Searching a word with or without first capital letter ever finds all results with this word, e.g. searching "Berlin" or "berlin" gives back same results.
          But: the highlighting span in extracts marks only the version typed in search form. Searching "berlin" marks only "berlin" in the results list but additionally shows all other results with unmarked "Berlin". Is there a way to adapt the search class marking both versions found and extracted?
          Which version of the Search_Highlight plugin do you use ? I can’t reproduce this issue. See this thread.
            • 24495
            • 407 Posts
            I don’t use the Search_Highlight plugin. What I meant was the "highlighting" of search terms at the search results page (not the document after following the result link). This issue was fixed perfectly by FS#45.

            Now my last problem is the ranking (two posts before) what I don’t understand. How does it work?

            EDIT: Tried Search_Highlight v1.3 now, works perfect, no problems with/without capitals!
              • 5811
              • 1,717 Posts
              @Rasc
              Now I tried
              Code:

              &order=`publishedon DESC` &rank=`pagetitle:100,extract`
              &order=`publishedon DESC` &rank=`pagetitle:100,longtitle:100,alias:100,extract`
              &order=`publishedon DESC` &rank=`pagetitle:100,longtitle:100,alias:100,extract:0`

              For all versions the results are same pages in same order.
              I have done the following tests - Try Education as searchTerm :
              On the modx demo site - (Php4.4.9) [EDIT: I have now upgraded the demo site to Php 5.2.6]
              - mode ajax : Sort with order and ranking parameters The test is correct. The first documents reach a ranking value of 139, the second one 137, the third 121 ...
              - mode non-ajax : Sort with order and ranking parameters. The results are totally wrong 12, 23, 5 ... >:(

              On my laptop (local) with Php 5.2.5, the two tests are correct and provide the same results as the test with mode ajax. So with have an issue with the mode non ajax and may be with versions of Php < 5.0. I have registered this issue under AJAXSEARCH-06 : Sort with order and ranking parameters. Results with a wrong order

              Which version of Php do you use ?
              If you want know the ranking values of your search results, simply add the following lines in your "results.tpl.html templates.
              [+as.rankShow:is=`1`:then=`
                <br /><span class="[+as.rankClass+]"><strong>Rank:</strong> [+as.rank+]</span><br /><br />
              `+]
              As I haven’t locally (with a debuuger) an environment with locally, it could be take time to understand the reason of this issue.
                • 24495
                • 407 Posts
                laugh Great work coroico! Keep calm with this issue.

                PHP was an earlier 5 version at my first tests. 2 weeks ago my provider changed to 5.2.6 and now the ranking works correct!
                Tested some options with order and rank (thanks for the hint showing the rank value) and all versions work right.

                I don’t know what are differences between the PHP5 versions but it seems that versions 5.2.5 and 5.2.6 work with correct ranking. Now its great! grin
                  • 19975
                  • 429 Posts
                  Quote from: coroico at Sep 16, 2008, 12:02 PM

                  In the version 1.8.1 currently in progress, the &whereSearch parameter is improved by adding the list of fields where to do the search

                  e.g: &whereSearch=`content:pagetitle,introtext|tv:tv_value|maxigallery:gal_title`

                  by default by default = "content|tv" allow the search in all the fields of content and tv values.


                  and the list of Tvs used by the search defined by the &withTvs parameter.

                  e.g: &withTvs=`+:tv1,tv5,tv8` use only tv1,tv5,tv8 for the search (&whereSearch)
                  e.g: &withTvs=`-:tv1,tv5,tv8` all tvs except tv1, tv5,tv8 are used


                  I’m using version 1.8.3
                  And in any case, all the data fields of the tables used will be available as placeholder for the display in templates.

                  [EDIT: Registered as ADDON-24]

                  Hi coroico ,

                  I’m getting mixed results, while I’m able to filter out content from my searches by using &whereSearch=`content:NULL|tv` I’m unable to get &withTvs to work nor am I able to get &whereSearch=`tv:tag` to work.

                  I can’t seem to filter my search to a select list of TVs sad


                  I’ve managed to get ajaxSearch to filter search by selected TV’s with the following code

                  &whereSearch=`content:NULL|tv` &withTvs=`+:tvTage1,tvTag2`


                    Martin Sanders - Design & Web Development