更新一个索引
- //更新多一个索引
- $index = new Zend_Search_Lucene(INDEX_DATA);
- Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
- $doc = new Zend_Search_Lucene_Document();
- $doc ->addField(Zend_Search_Lucene_Field::unStored('key',md5($rid),'utf-8'));
- $doc ->addField(Zend_Search_Lucene_Field::text('logTitle',$data['logTitle'],'utf-8'));
- $doc ->addField(Zend_Search_Lucene_Field::text('logContent',$data['logContent'],'utf-8'));
- $index->addDocument($doc);
- $index ->optimize();
- $index->commit();
//更新多一个索引 $index = new Zend_Search_Lucene(INDEX_DATA); Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive()); $doc = new Zend_Search_Lucene_Document(); $doc ->addField(Zend_Search_Lucene_Field::unStored('key',md5($rid),'utf-8')); $doc ->addField(Zend_Search_Lucene_Field::text('logTitle',$data['logTitle'],'utf-8')); $doc ->addField(Zend_Search_Lucene_Field::text('logContent',$data['logContent'],'utf-8')); $index->addDocument($doc); $index ->optimize(); $index->commit();
删除索引
- //删除索引
- $index = new Zend_Search_Lucene(INDEX_DATA);
- Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');//设置查询器编码,搜索中文必须!
- $hits = $index ->find(md5($id));
- foreach ($hits as $hit){
- $index->delete($hit->id);
- }
- $index -> commit();
//删除索引 $index = new Zend_Search_Lucene(INDEX_DATA); Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');//设置查询器编码,搜索中文必须! $hits = $index ->find(md5($id)); foreach ($hits as $hit){ $index->delete($hit->id); } $index -> commit();
修改索引
- //更新修改索引
- $index = new Zend_Search_Lucene(INDEX_DATA);
- Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
- Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');//设置查询器编码,搜索中文必须!
- $hits = $index ->find(md5($id));
- foreach ($hits as $hit){
- $index->delete($hit->id);
- }
- $doc = new Zend_Search_Lucene_Document();
- $doc ->addField(Zend_Search_Lucene_Field::unStored('key',md5($id),'utf-8'));
- $doc ->addField(Zend_Search_Lucene_Field::text('logTitle',$data['logTitle'],'utf-8'));
- $doc->addField(Zend_Search_Lucene_Field::text('logContent',$data['logContent'],'utf-8'));
- $index->addDocument($doc);
- $index->optimize();
- $index -> commit();