I noticed that I seemingly wasn't able to sort on relevance in a default search. Whether I tried ASC or DESC, the results were always the same and rather poorly relevant at that.
Upon further investigating, I found the addSearchFilter() method in Mage_CatalogSearch_Model_Resource_Fulltext_Collection :
/**
* Add search query filter
*
* @param string $query
* @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
*/
public function addSearchFilter($query)
{
Mage::getSingleton('catalogsearch/fulltext')->prepareResult();
$this->getSelect()->joinInner(
array('search_result' => $this->getTable('catalogsearch/result')),
$this->getConnection()->quoteInto(
'search_result.product_id=e.entity_id AND search_result.query_id=?',
$this->_getQuery()->getId()
),
array('relevance' => 'relevance')
);
Zend_Debug::dump($this->getData());exit;
return $this;
}
The result of my data dump shows the results just fine, but the 'relevance' column is always 0.00000. I have not made any changes to the catalog search and this is Magento 1.6.0.
I dumped the actual SQL as well:
SELECT `e`.*, `search_result`.`relevance` FROM `catalog_product_entity` AS `e` INNER JOIN `catalogsearch_result` AS `search_result` ON search_result.product_id=e.entity_id AND search_result.query_id='33'
If anyone else has more experience with calculating relevance I would greatly appreciate direction.