Lack of interest Admin quick search relevancy

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

refael

Well-known member
Not sure if bug or not.
I've noticed that the admin quick search gives not so relevant results at times.

If you will search the word: "message", in order to find that template, it won't show up in the results. Instead, you'll see other template results which contain that word.
I think that template name which start with that word, would be more relevant than strings that have the word in the middle/end.
You can test the same with the word "post".
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
Relevancy isn't something that we even attempt to do. As said, matching results are simply listed alphabetically. Relevancy (of some form, given that we're just doing a "like" search) would have to be a suggestion... so I'll just move this.
 
Guess it won't be fixed in the near future, so I've fixed that for myself.
if anyone interested, the code below will add relevancy for templates search:
/library/XenForo/Model/Template.php

PHP:
public function getEffectiveTemplateListForStyle($styleId, array $conditions = array(), $fetchOptions = array())
{
    $whereClause = $this->prepareTemplateConditions($conditions, $fetchOptions);
    $limitOptions = $this->prepareLimitFetchOptions($fetchOptions);

    $titleRelevancy = '';
    if(isset($conditions['title']))
        $titleRelevancy = '(CASE WHEN template.title LIKE \''.$conditions['title'].'%\' THEN 0 ELSE 1 END),';

    return $this->_getDb()->fetchAll($this->limitQueryResults('
        SELECT template_map.template_map_id,
            template_map.style_id AS map_style_id,
            template.template_id,
            template.title,
            addon.addon_id, addon.title AS addonTitle,
            IF(template.style_id = 0, \'default\', IF(template.style_id = template_map.style_id, \'custom\', \'inherited\')) AS template_state,
            IF(template.style_id = template_map.style_id, 1, 0) AS canDelete
        FROM xf_template_map AS template_map
        INNER JOIN xf_template AS template ON
            (template_map.template_id = template.template_id)
        LEFT JOIN xf_addon AS addon ON
            (addon.addon_id = template.addon_id)
        WHERE template_map.style_id = ?
            AND ' . $whereClause . '
        ORDER BY ' . $titleRelevancy . ' CONVERT(template_map.title USING utf8)
    ', $limitOptions['limit'], $limitOptions['offset']), $styleId);
}
 
Top Bottom