We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16308
    • 23 Posts
    Hey guys

    Been using Modx now for a couple of years. I’ve recently finished a project with included ajaxsearch.

    The issue we’re having is that the search is just too sensitive.

    For example, a search for Air will bring up results for Chair.

    Is there anyway to lower this sensitivity to allow the search to only pick up whole words, and not just parts?

    Thanks for any advice!
      • 5811
      • 1,717 Posts
      Is there anyway to lower this sensitivity to allow the search to only pick up whole words, and not just parts?
      No, it’s not possible. This is due to mysql. When you run a sql request with - where field LIKE ’%air%’ - , you get all the possible terms like ’chairs’, ...

      And if you run a search with - where field LIKE ’air’ -, you get nothing if the field contains some other words.
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        You can write MySQL queries that look for whole word matches, but that’s just not how the Ajax Search queries are programmed.
          • 5811
          • 1,717 Posts
          You can write MySQL queries that look for whole word matches, but that’s just not how the Ajax Search queries are programmed.
          Except by using the full text search mode of MySQL, effectively I don’t know how I could offer a whole word search.
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            I’m not sure what you mean by "full text search mode", but you can use queries like this:

             WHERE `column_name` REGEXP '[[:<:]](wholeword)[[:>:]]'


            Is that the full text search mode?
              • 5811
              • 1,717 Posts
              Is that the full text search mode?
              No the full text search Mysql mode is described here

              But you are right, REGEXP could be the solution. I could probably change the "exact phrase" mode of the &advSearch parameter to exactly fit a word or a phrase. Thanks for this suggestion.
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                Thanks for the link. Yeah, I’ve seen full text searches in action, but I didn’t realize MySQL had a whole set of operations set aside for them. I think they’re most useful if you’ve got a set of stop-words (e.g. "and", "the", etc)... for searching a single site, the REGEXP may be the way to go...
                  • 15076
                  • 43 Posts
                  a dirty trick may be to put a space before the searchword. this way you will find all words that are equal to ’ air’, with exact word combination, this may be able to work? Dont use a space after, because you will ignore words on the end of a sentence, because they normally have a . or ! or ? etc.

                  It may be easier to implement:)