Admin search setting description "Maximum results to show" is misleading

Started by ioszilla, August 12, 2007, 03:44:17 PM

Previous topic - Next topic

ioszilla

I was coding my smf search enhancement mod when I noticed this line in Search.php (smf 1.1.3):

Line #258:

Quote
$maxMessageResults = empty($modSettings['search_max_results']) ? 0 : $modSettings['search_max_results'] * 5;


$maxMessageResults corresponds to a value set for "Maximum results to show" in Admin -> Search -> Settings, and is defaulted to 0;

Now the problem is:

If "Maximum results to show" is set to non-zero, it does not only limit the number of results pages as it appears, it actually will also limit the internal raw result set (before the assignment of relevance score).


Suppose the user sets "Number of search results per page" to 30, and "Maximum results to show" to 900. It may appear that the search will display 30 result pages (900/30) ordered by relevance score (descending), if the number of potential matching topics exceeds 900. Sounds good, but it's NOT the case. What happens is that the search only processes the 4500 (900*5) internal matches (even if there are more) and displays 900 most relevant matches from the 4500 matches.

As evidenced by lines 939-946, and similarly, lines 1097-1104:
      
Quote
         WHERE " . implode("
             AND ", $subject_query['where']) . (empty($modSettings['search_max_results']) ? '' : "
         LIMIT " . ($modSettings['search_max_results'] - $numSubjectResults)), __FILE__, __LINE__);

    $numSubjectResults += db_affected_rows();
            
   if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
   break;


If some of our most relevant topics (against the user query) happen to be match #4501, #4502,... -- them will not appear in the output result pages as they are pre-excluded from results before relevance scores are assigned.

I'm able to confirm this as I compared results generated by our live smf forum (Maximum results to show: 900) and by backup smf forum (0: unlimited). A most relevant topic (ranked #2) was missing on the live forum simply because it was posted last year (since then more than 4500 matching posts against the user query was posted).


The bottom line:

Setting "Maximum results to show" to non-zero may well cause most revelant matching topics to fail to show up in user search results completely.

"Maximum results to show" description gives false impression that the search is ignoring the rest of all matching topics simply because they are less relevant, which is not the case - and thus may mislead forum admin.


- wordzilla


Advertisement: