Increasing the Search Limit in Joomla to More than 20 Characters

If you have tried to search for a very long sentence in Joomla, then most likely the only result that you got was the following:

Search term must be a minimum of 3 characters and a maximum of 20 characters.

If you really want people to search for long sentences on your website, then obviously you want to change that upper limit. But how to do that?

Well, before we tell you how, we have to say that the first time we tried to increase the maximum search limit it took us ages to find out how – it was like a wild goose chase: a file leading you to another file which leads to another file! But, we finally discovered it: it was actually a language setting! We have no idea why Joomla doesn’t have this setting in a place that is obvious – such as in the settings of the menu item pointing to the search component.

To make things even more complicated, that setting cannot be changed in Joomla’s backend, but rather in the language file (in other words, you’ll need to do some coding). So, if you want to change the maximum search limit (and assuming that you have only one language on your website, which is English), then here’s how you do this:

  • You open the file en-GB.localise.php located under the /language/en-GB/ folder.
  • In the function getUpperLimitSearchWord, you change the return value from 20 to 40 (for example). In other words, you change the following code:

    return 20;

    to

    return 40;

  • You save the file and you upload it!

  • That’s it!

Now, one thing to mention, if you have other languages then you need to do the same steps above for each one of them (for example, if your website has a French version, then you will need to do the above modifications to the file fr-FR.localise.php located under the /language/fr-FR/ directory). If you don’t have the time to do this tedious job, then you can instead do the following change to a Joomla core file to make sure that all languages have the same search limit of your choice:

  • Open the file language.php which is located under the libraries/joomla/language directory.
  • Just before this line (line 582):

    if ($this-&upperLimitSearchWordCallback !== null)

    add the following code:

    return 40; //where 40 is your new search limit

  • Save the file and upload it back.

  • That’s it!

Note that Joomla’s search module, by default, has its maxlength set to 20 – that’s why you’re not able to enter more than 20 characters in the search field of that module. However, the good news is that the maxlength value comes from the function getUpperLimitSearchWord, which means that doing the above will automatically ensure that maxlength is changed to your value of choice (for example, if you changed the value to 40 then the maxlength value will be automatically 40).

Now, if the above hasn’t worked for you or if you don’t have the programming experience to do it – then why not contact us? We’ll fix the issue for you in the speed of light (well, a bit slower, but you get the point), we won’t charge you much, and we are the friendliest programmers on planet Earth – maybe even the whole solar system!

Note: If you want to increase/decrease the lower search limit, then just replace the word upper with lower in the above guide and you’ll be all set. For example, instead of changing the return value of the function getUpperLimitSearchWord, you will need to change the return value of the function getLowerLimitSearchWord.

2 Responses to “Increasing the Search Limit in Joomla to More than 20 Characters”
  1. Comment by Jeff Honeyager — August 5, 2014 @ 4:02 pm

    Perfecto!

    Thanks for taking time to post this. I started down the path of hunt and peck. I was about to grep the site and thought I’ll google one more time.

    Presto Change-o 2 minutes later and my site is searching for strings of 50 chars.

    Thanks!!!

  2. Comment by Sharon — January 4, 2015 @ 8:41 am

    I am working on my website on local host and searched for this resolution all day yesterday. I could not find the answer to this at all until I came across your post this morning.

    Many thanks – very much appreciated!!

    Sharon

Leave a comment