You are here:  » Advantages BOOLEAN MODE


Advantages BOOLEAN MODE

Submitted by Eddie on Tue, 2006-11-14 09:34 in

David,

What are the advantages of using the BOOLEAN MODE as in http://www.pricetapestry.com/node/420 ?

Also I have looked in the latest version of PT in search.php line 63 and cant see the

if (strlen($parts[0]) > 3)

Where would I put the code:

<?php
        if (strlen($parts[0]) > 3)
        {
          $match = "+".str_replace(" "," +",$parts[0]);
          $sql = "SELECT *, MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH name AGAINST ('".database_safe($match)."' IN BOOLEAN MODE) AS relevance FROM `".$config_databaseTablePrefix."products` WHERE MATCH name AGAINST ('".database_safe($match)."' IN BOOLEAN MODE) GROUP BY name";
          $sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE MATCH name AGAINST ('".database_safe($match)."' IN BOOLEAN MODE)";
          $orderBySelection = $orderByFullText;
        }
        else
        {
          // .... rest of script .....
?>

Thanks

Eddie

Submitted by support on Tue, 2006-11-14 10:35

Hi Eddie,

Boolean mode will mean that ALL words must be present in the product name in order to match. Some users prefer this; however it is less likely to return results if a user is unsure of what they are looking for. For example, if somebody searches for "Sony Plasma", boolean mode would only return Sony Plasmas, and if you didn't have any in your database there would be no results. The non boolean mode (as per the distribution) would still return results containing Plasma, so you would still get "hits" to the other Plasmas that you may be promoting.

The other disadvantage of boolean mode is that you are less likely to keep traffic from people unsure of spelling - in particular with regards to the way model numbers are formatted.

To add the code, look for the default case in the switch statement that decides what SQL to construct for the query. You should find the following code:

      default:
        if (strlen($parts[0]) > 3)
        {
          $sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH name AGAINST ('".database_safe($parts[0])."') AS relevance FROM `".$config_databaseTablePrefix."products` WHERE MATCH name AGAINST ('".database_safe($parts[0])."') GROUP BY name";
          $sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE MATCH name AGAINST ('".database_safe($parts[0])."')";
          $orderBySelection = $orderByFullText;
        }

That is the block of code that you need to replace - everything between the curly brackets.