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

    an example:
    when I do look up the word "table" with AjaxSearch I will also find as a result the word "tabledance", as "table" is a part of "tabledance".
    What I need is a posibility to really only get the results corresponding to the search-phrase, in this case "hand"

    I looked up the MODx-Wiki and tried using the following parameter:
    &advSearch=`exactphrase `

    Only, it does not work... it keeps finding "tabledance"

    Does anyone have an idea how to configure AjaxSearch, so that it does only look for the exact phrase?
      • 5811
      • 1,717 Posts

      &advSearch=`exactphrase` - With one search term, is equivalent to &advSearch=`oneword`

      exactphrase means that if you use "word1 word2" you don’t get results with word1 or results with word2 or "word1 word2" but only the exact phrase "word1 word2".

      See http://www.modx.wangba.fr/sql.html for more information. The use of "LIKE ’%word1%’" catch all the words whick like *word1*
        • 12461
        • 22 Posts
        Quote from: coroico at Apr 23, 2008, 10:45 AM


        &advSearch=`exactphrase` - With one search term, is equivalent to &advSearch=`oneword`

        exactphrase means that if you use "word1 word2" you don’t get results with word1 or results with word2 or "word1 word2" but only the exact phrase "word1 word2".

        See http://www.modx.wangba.fr/sql.html for more information. The use of "LIKE ’%word1%’" catch all the words whick like *word1*

        Hello,

        thank you very much for the link, thats very helpfull *thumbs-up*

        Now I do understand more of the logic "behind" AjaxSearch.

        Now, as far as I understand I will mostly get a search working like this: OR sc.description LIKE ’%word1%’ ... and so on
        What I seem to need is somewhat like this: OR sc.description = ’word1’

        Do you think there is a way to produce such a search-string?
          • 5811
          • 1,717 Posts
          To do a "exactword" search you need to change the function dosearch in the file includes/ajaxSearch.inc.php. For that adds around the line 121 a new type of search like :
              $orlike2 = " (sc.pagetitle LIKE 'word' OR sc.longtitle LIKE 'word' OR sc.description LIKE 'word' OR sc.introtext LIKE 'word' OR sc.content LIKE 'word' OR stc.value LIKE 'word') ";
          And modify the switch section by adding the lines :
              case 'exactword':
                $search[0] = $searchString;
                $whdoc = $orlike2;
                $docop = '';
                break;
          And use &advSearch=`exactword`.
          Try it and let me know the results. But keep in mind that the highlight plugin could enhance a word like "tabledance" before to find "table" in the text.
            • 12461
            • 22 Posts
            Hello coroico,

            I do thank you very much for your help.
            Actually it works, yes...

            Now, I will have a talk with my customer who wanted this feature because I do not find it very usefull in terms of a smart search. When I do search for just one word, i will get a problem if the word stands at the end of a sentence for example. At the end of the sentence the word will be followowed by a dot, I mean a "." In this case the word will not be found, as will be the case with a word followed by a comma "," or some other character. The system is "dumb" and does not know where a word beginns and where it ends. I think it is quite useless to programm a workaround filtering all the possible characters that can stand before or after a word.

            Well, as happens so often... it took me quite a few hours for this bit of learning... undecided

            Thank you again for your help.