You are here:  » Boolean search option or default

Support Forum



Boolean search option or default

Submitted by tbbd2007 on Fri, 2008-03-14 23:17 in

David,

Is it possible to offer the option of a Boolean search using the terms used in the search box or to make it the default search? Boolean essentially acts by only displaying searches found matching all the terms used. With the current search system if I were searching for something like 'Sony Ericsson W850i' I would get results matching the individual terms of 'Sony' + 'Ericsson' + 'W850i' where as a Boolean search would only display results that have 'Sony' + 'Ericsson' + 'W850i' in them which would display the true match of what someone is looking for instead of everything matching each individual term.

Please let me know if this is possible.

Thanks,

Stephen
Online Shopping For
The Big Business Directory

Submitted by support on Sat, 2008-03-15 09:41

Hello Stephen,

There is some discussion about this (including MySQL version requirements) in the following thread:

http://www.pricetapestry.com/node/1238

To summarise the code change, in search.php, look for the following full text search code, beginning at line 77:

        if ($useFullText)
        {
          $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;
        }

...and change to:

        if ($useFullText)
        {
          $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;
        }

Cheers,
David.

Submitted by tbbd2007 on Sat, 2008-03-15 10:13

David,

Thanks for that, it works perfectly.

Stephen
Online Shopping For
The Big Business Directory