?
avatar fevangelou
fevangelou
14 Nov 2014

Joomla limits any search query to a small 20 characters string by default. Anything beyond that is simply cut off and no search is performed.

The limit is hardcoded within the file /language/en-GB/en-GB.localise.php for English and I assume similar xx-XX.localise.php files in other languages packs.

Since this essentially cripples the search functionality in Joomla, I propose we leave these hardcoded limits in place and add a new option under com_search's component parameters to override the default limit for ANY language (seriously, there is no point in having different search limits per language).

In order to do this properly, numerous files in Joomla need to be patched to pass on this setting.

If the Joomla core team is willing to accept this, I'll be glad to create the PR for this and submit it for inclusion.

avatar fevangelou fevangelou - open - 14 Nov 2014
avatar jissues-bot jissues-bot - change - 14 Nov 2014
Labels Added: ?
avatar chrisdavenport
chrisdavenport - comment - 14 Nov 2014

Wouldn't it be simpler to support zero as meaning no limit in the localise.php files?

I'm guessing that the different limits per language are to support those languages that require multi-byte encoding.

avatar fevangelou
fevangelou - comment - 14 Nov 2014

Yes, you're right. Having no (upper) limit or some large value (e.g. 500) is simpler as having one more thing to configure for the obvious is probably too much. I mean, user probably barely know com_search has options...

Certainly the easiest thing to do is remove the limit.

avatar RCheesley
RCheesley - comment - 14 Nov 2014

I'd also think it would be better to remove the limit than worry about
imposing a specified limit, unless there are any implications in terms of
queries being made for long strings?

Ruth

On 14 November 2014 17:18, Fotis Evangelou notifications@github.com wrote:

Yes, you're right. Having no (upper) limit or some large value (e.g. 500)
is simpler as having one more thing to configure for the obvious is
probably too much. I mean, user probably barely know com_search has
options...

Certainly the easiest thing to do is remove the limit.

Reply to this email directly or view it on GitHub
#5103 (comment).

Be like me, be Carbon free - don't print this and save a tree
IMPORTANT: The contents of this email and any attachments are confidential.
They are intended for the named recipient(s) only. If you have received
this email by mistake, please notify the sender immediately and do not
disclose the contents to anyone or make copies thereof.

avatar fevangelou
fevangelou - comment - 14 Nov 2014

I doubt there is - perhaps from a performance standpoint for large site deployments with GBs of data records (but I guess only the devs of MySQL know that) :)

avatar SniperSister
SniperSister - comment - 14 Nov 2014

If it doesn't have any performance implications I would vote for removing it too. I tried to find out why it has been added, but it seems to be in the code since forever and I could find any hints on that.

Any SQL experts in here that could provide us some help?

avatar ot2sen
ot2sen - comment - 14 Nov 2014

In the past, it has been discussed forever, it was suggested to set a high limit configurable. Various inputs in this thread from 2008 https://groups.google.com/forum/#!topic/joomlabugsquad/q7D9s1_26EA

avatar fevangelou
fevangelou - comment - 14 Nov 2014

Funny, 200 is what I modified joomlaworks.net to be :)

avatar SniperSister
SniperSister - comment - 14 Nov 2014

So, we have three proposals on the table:

  1. leave the com_search code as it is, and instead the limit in the localise.php to 200: easy, fast
  2. make the limit configurable and add a default of 200: cleaner solution but a a bit more complex to implement
  3. remove the limit: might cause unknown sideeffects

Depending on the amount of time you can invest, I would work for either 1 or 2

avatar fevangelou
fevangelou - comment - 14 Nov 2014

I'd recommend no. 1 - PR issued in 5 secs :)

avatar chrisdavenport
chrisdavenport - comment - 14 Nov 2014

I'd go for 1 too. Does modifying the non-English localise.php files require coordination with the language teams? @infograf768

avatar brianteeman brianteeman - change - 15 Nov 2014
Category Search
avatar brianteeman brianteeman - change - 15 Nov 2014
Status New Pending
avatar infograf768
infograf768 - comment - 15 Nov 2014

@chrisdavenport @fevangelou
I suggest to modify the method in JLanguage so that we get:

    /**
     * Returns an upper limit integer for length of search words
     *
     * @return  integer  The upper limit integer for length of search words (200 if no value was set or if default value is < 200 for a specific language).
     *
     * @since   11.1
     */
    public function getUpperLimitSearchWord()
    {
        if ($this->upperLimitSearchWordCallback !== null || $this->upperLimitSearchWordCallback < 200)
        {
            return call_user_func($this->upperLimitSearchWordCallback);
        }
        else
        {
            return 200;
        }
    }

This will not bother Translation Teams.

avatar infograf768
infograf768 - comment - 15 Nov 2014

I have corrected the code in the above post

avatar chrisdavenport
chrisdavenport - comment - 15 Nov 2014

Or how about this (which also ensures that the upper limit if >= the lower limit):

/**
 * Returns an upper limit integer for length of search words
 *
 * @return  integer  The upper limit integer for length of search words (200 if no value was set for a specific language).
 *
 * @since   11.1
 */
public function getUpperLimitSearchWord()
{
    $bound = 200;

    // Get the language-specific upper limit if there is one.
    $upperLimit = $this->upperLimitSearchWordCallback !== null ? call_user_func($this->upperLimitSearchWordCallback) : $bound;

    // Make sure that upper limit lies within proper bounds.
    $upperLimit = max(min($upperLimit, $bound), $this->getLowerLimitSearchWord());

    return $upperLimit;
}
avatar fevangelou
fevangelou - comment - 15 Nov 2014

JM's tweak looks cleaner to my eye.

avatar chrisdavenport
chrisdavenport - comment - 15 Nov 2014

Maybe, but JM's tweak won't work. ;-)

avatar infograf768
infograf768 - comment - 16 Nov 2014

In fact, just tested both, and both don't work...
I just did a var_dump of $upper_limit in mod_search.php and always get the language xx-XX.localise.php setting.
This is obtained in both component and module by
$upper_limit = $lang->getUpperLimitSearchWord();

Looks like we have an issue here going further. :)

avatar infograf768
infograf768 - comment - 16 Nov 2014

OK, found out :
it should be
if ($this->upperLimitSearchWordCallback !== null && call_user_func($this->upperLimitSearchWordCallback) > 200)

avatar infograf768
infograf768 - comment - 16 Nov 2014

And I guess, in Chris proposal
// Make sure that upper limit lies within proper bounds.
$upperLimit = max(min($upperLimit, $bound), call_user_func($this->getLowerLimitSearchWord()));

avatar chrisdavenport
chrisdavenport - comment - 16 Nov 2014

Hehe. Well use what works, but drop the else that is wrapping the return 200. It isn't needed.

avatar infograf768
infograf768 - comment - 16 Nov 2014

Without the else, we get a null value... :)
Please test #5121

avatar infograf768
infograf768 - comment - 16 Nov 2014

dropped the else, thanks Chris.

avatar chrisdavenport
chrisdavenport - comment - 16 Nov 2014

What I meant was change:

if (...)
{
return ...
}
else
{
return ...
}

to:

if (...)
{
return ...
}

return ...

avatar chrisdavenport
chrisdavenport - comment - 16 Nov 2014

Oh, you've already done it. Thanks. :-)

avatar infograf768
infograf768 - comment - 16 Nov 2014

Please confirm #5121

avatar infograf768
infograf768 - comment - 16 Nov 2014

closing this as we have a a patch

avatar infograf768 infograf768 - close - 16 Nov 2014
avatar infograf768 infograf768 - change - 16 Nov 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-11-16 11:13:43

Add a Comment

Login with GitHub to post a comment