コンソール コマンドで zend lucene を使用して、3000 を超えるレコードを含むテーブルのインデックスを作成しようとしています。
ここに私のコードがあります
public function run($args) {
set_time_limit(0);
Yii::import('application.vendors.*');
require_once 'Zend/Search/Lucene.php';
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(
new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive ()
);
$searchPath = Yii::app()->runtimePath.'/search';
$index = Zend_Search_Lucene::create($searchPath);
/*
* fecth data to index
*/
$sql = 'select id, title, content, succinct, create_time from `news` where status="published"';
$query = Yii::app()->db->createCommand($sql);
$result = $query->queryAll();
foreach ($result as $data) {
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('title',
CHtml::encode($data['title']), 'UTF-8')
);
$doc->addField(Zend_Search_Lucene_Field::Text('succinct',
strip_tags($data['succinct']), 'UTF-8')
);
$doc->addField(Zend_Search_Lucene_Field::UnStored('content',
strip_tags($data['content']), 'UTF-8')
);
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('newsId',
$data['id'], 'UTF-8')
);
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('create_time',
$data['create_time'], 'UTF-8')
);
$index->addDocument($doc);
}
$index->commit();
$index->optimize();
}
}
しかし、私はこのエラーが発生します
メモリ不足 (228480 バイトが必要)
例外 'CDbException' とメッセージ 'CDbCommand が SQL ステートメントの実行に失敗しました: SQLSTATE[HY000]: 一般エラー: 2008 MySQL クライアントでメモリが不足しました。実行された SQL ステートメントは次のとおりですnews
。
なにか提案を ?