1
votes

Does anyone know the code that passes the search term to solr search engine in Magento. For example, when you search for "spider man" in the search bar on the Front end, where is the code, the template file, the module and the php class that passes this search term to the solr search engine or the magento default fulltext search engeine.

I am stocked after finding this code, app/code/core/Mage/CatalogSearch/controllers/ResultController.php

/**
 * Display search result
 */
public function indexAction()
{
    $query = Mage::helper('catalogsearch')->getQuery();
    /* @var $query Mage_CatalogSearch_Model_Query */

    $query->setStoreId(Mage::app()->getStore()->getId());

    if ($query->getQueryText() != '') {
        if (Mage::helper('catalogsearch')->isMinQueryLength()) {
            $query->setId(0)
                ->setIsActive(1)
                ->setIsProcessed(1);
        }
        else {
            if ($query->getId()) {
                $query->setPopularity($query->getPopularity()+1);
            }
            else {
                $query->setPopularity(1);
            }

            if ($query->getRedirect()){
                $query->save();
                $this->getResponse()->setRedirect($query->getRedirect());
                return;
            }
            else {
                $query->prepare();
            }
        }

        Mage::helper('catalogsearch')->checkNotes();

        $this->loadLayout();
        $this->_initLayoutMessages('catalog/session');
        $this->_initLayoutMessages('checkout/session');
        $this->renderLayout();

        if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
            $query->save();
        }
    }
    else {
        $this->_redirectReferer();
    }
}
1
Are you using the open source (CE) or commercial (Enterprise) edition? By default the open source / Community Edition doesn't call solr, though you can download the Magentix Solr stuff (has some issues, notice the many branches), here github.com/magentix/SolrMark Bennett
I am using the Enterprise version 1.12s-hunter
Sorry, I haven't looked at the Enterprise stuff. I wouldn't think we could see all the code in the Enterprise version? Maybe just the parts it has in common with the CE version? So I'd suspect the Solr-specific integration code would not be entirely visible?Mark Bennett

1 Answers

1
votes

In the file app/code/core/Enterprise/Search/Model/Adapter/HttpStream.php The function is:

protected function _search($query, $params = array())

The line that sends the query to solr:

    $response = $this->_client->search(
        $searchConditions, $offset, $limit, $searchParams, Apache_Solr_Service::METHOD_POST
    );