2015-03-23 4 views
0
public function searchIndex($entity) 
    { 
     //http://framework.zend.com/manual/2.0/en/modules/zendsearch.lucene.searching.html# 
     //http://stackoverflow.com/questions/7805996/zend-search-lucene-matches 
     //http://framework.zend.com/manual/2.0/en/modules/zendsearch.lucene.index-creation.html 
     try { 
      $index = Lucene::open($this->getOptions()->getIndexDir()); 
      $index->optimize(); 

      echo '<p>Index optimized.</p>'; 
     } catch (Exception $e) { 
      throw new Exception("Search index not configured", 1); 
     } 

     $query = QueryParser::parse($entity->getTerm()); 

     $hits = $index->find($query); 

     //print_r($hits); 
     $entity->setCount(count($hits)); 

     //save the search for reference 
     $this->create($entity); 

     return $hits; 
    } 

Каждый раз, когда я действительно выполнять поиск в моем ZEND сайте, это дает мне нулевой результат, пожалуйста, скажите мне кто-то, как выполнить индексирование в Зенд.Как мы можем сделать весь сайт переиндексацию поиска Lucene

ответ

0

Я решил проблему, ее проблему с реиндексом. Когда мы обновляем страницу, нам нужно создавать индексы. Я исправил это, используя следующий код.

public function getbuild() 
    { 
     if (!$this->searchService) { 
      $this->setSearchService($this->getServiceLocator()->get('SearchEntity\Service\Indexer')); 
     } 

     return $this->searchService; 
    } 

Просто позвоните в файл вашего контроллера. Он снова построит индексы.

Смежные вопросы