简体   繁体   English

将搜索词传递给Magento中的solr搜索引擎的代码在哪里

[英]Where is the code that passes the search term to solr search engine in Magento

Does anyone know the code that passes the search term to solr search engine in Magento. 有谁知道将搜索词传递给Magento中的solr搜索引擎的代码。 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. 例如,当您在前端的搜索栏中搜索“蜘蛛侠”时,将此搜索词传递给solr搜索引擎或magento默认全文的代码,模板文件,模块和php类在哪里?搜索金鸡菊。

I am stocked after finding this code, app/code/core/Mage/CatalogSearch/controllers/ResultController.php 找到此代码后,我就放养了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();
    }
}

In the file app/code/core/Enterprise/Search/Model/Adapter/HttpStream.php The function is: 在文件app / code / core / Enterprise / Search / Model / Adapter / HttpStream.php中,该函数是:

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

The line that sends the query to solr: 将查询发送到solr的行:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM