0
你好,我正在嘗試構建Lucene索引。我有問題在服務器上建立索引中斷,在本地主機上工作。我發現某處可能是一個問題,因爲大量的數據我不知道爲什麼。在服務器上,我更改max_execution時間和time_limit。我打電話給這個方法Zend Lucene索引
static public function indexSearchJedinice($params = null)
{
$debug_file_path = 'c:/wamp/www/linkdl/debug/element.txt';
$debug_file = fopen($debug_file_path, 'w');
fwrite($debug_file, 'uso' ."\n");
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
// Create index. Will delete any existing index.
$index = Zend_Search_Lucene::open('c:/wamp/www/linkdl/lucene/jedinice/');
$sql = "
SELECT DISTINCT KNJ.ID, KNJ.Naziv, KNJ.Opis, KNJ.UID
FROM Kurs as K
LEFT JOIN KursPodaci as KP on K.ID = KP.IDKurs
INNER JOIN KursPripadaGrupi as KPG ON K.ID = KPG.IDKurs
INNER JOIN PodGrupa ON PodGrupa.ID = KPG.IDPodgrupa
INNER JOIN KursSadrziNastavneModule ON KursSadrziNastavneModule.IDKurs = K.ID
INNER JOIN KursModulSadrziJedinicu on KursModulSadrziJedinicu.IDKursNastavniModul = KursSadrziNastavneModule.IDKursNastavniModul
INNER JOIN KursNastavnaJedinica as KNJ ON KNJ.ID = KursModulSadrziJedinicu.IDKursNastavnaJedinica
WHERE K.ProdajniStatus IN (0,1)
AND KPG.IDCenovnikTip = 2
AND KNJ.JeZaPrikazivanje = 0
";
//fwrite($debug_file, $sql ."\n");
if ($jedinice = Db::getResult($sql))
{
foreach ($jedinice as $jedinica)
{
//fwrite($debug_file, $jedinica['Naziv'] ."\n");
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('ID', $jedinica['ID']));
$doc->addField(Zend_Search_Lucene_Field::Text('Naziv', $jedinica['Naziv'], 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnStored('Opis', $jedinica['Opis'], 'utf-8'));
//$doc->addField(Zend_Search_Lucene_Field::UnStored('Opis', '', 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('UID', $jedinica['UID']));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('Type', 'jedinica'));
$kratki_tekst = str_replace(' ', '', str_replace('U izradi', '', strip_tags($jedinica['Opis'])));
$kratki_tekst = create_short_text($kratki_tekst, 475);
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('KratkiOpis', $kratki_tekst, 'utf-8'));
$index->addDocument($doc);
/**
* Optimizacija indeksiranja
*/
unset($doc);
}
}
fwrite($debug_file, 'Optimizacija pocinje' ."\n");
$index->commit();
$index->optimize();
fwrite($debug_file, 'Optimizacija zabrsena' ."\n");
return true;
}
有人可以幫助我瞭解open /和create之間的區別。 而這個選項不索引,不保存,文字