本文整理汇总了PHP中Zend_Search_Lucene_Interface::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Interface::delete方法的具体用法?PHP Zend_Search_Lucene_Interface::delete怎么用?PHP Zend_Search_Lucene_Interface::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene_Interface
的用法示例。
在下文中一共展示了Zend_Search_Lucene_Interface::delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Index a file
*
* @param string $filePath The file path
*/
public function index($filePath)
{
$content = file_get_contents($filePath);
$modificationTime = filemtime($filePath);
$checksum = md5($content);
// Get the document
$hits = $this->_data->find('path:' . $filePath);
if (count($hits) > 0) {
$hit = $hits[0];
$document = $hit->getDocument();
// If the checksums are the same, no need to update
if ($checksum === $document->checksum) {
return;
}
// Delete the document
$this->_data->delete($hit);
}
// Create a new document
$document = new Zend_Search_Lucene_Document();
$document->addField(Zend_Search_Lucene_Field::keyword('path', $filePath));
$document->addField(Zend_Search_Lucene_Field::keyword('modificationTime', $modificationTime));
$document->addField(Zend_Search_Lucene_Field::keyword('checksum', $checksum));
$document->addField(Zend_Search_Lucene_Field::unStored('content', $content, 'utf-8'));
$this->_data->addDocument($document);
// Commit the changes
$this->_data->commit();
$this->_data->optimize();
}
示例2: delete_post
/**
* Remove a post from the index
*
* @param Post $post the post being deleted
*/
public function delete_post($post)
{
$term = new Zend_Search_Lucene_Index_Term($post->id, 'postid');
$docIds = $this->_index->termDocs($term);
foreach ($docIds as $id) {
$this->_index->delete($id);
}
}
示例3: removeFromIndex
public static function removeFromIndex($term)
{
$websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
$searchIndexFolder = $websiteHelper->getPath() . 'cache/' . Widgets_Search_Search::INDEX_FOLDER;
if (!is_dir($searchIndexFolder)) {
return false;
}
if (!self::initIndex()) {
return false;
}
$hits = self::$_index->find(strval($term));
if (is_array($hits) && !empty($hits)) {
foreach ($hits as $hit) {
self::$_index->delete($hit->id);
}
return true;
}
return false;
}
示例4: delete
/**
* Remove a record from the search index
*
* @param string $value
* @param string $searchField
* @return Zym_Search_Lucene_Index
*/
public function delete($value, $searchField = null)
{
if (!$searchField) {
$searchField = $this->_idKey;
}
$documentIds = $this->getDocumentIds($value, $searchField);
foreach ($documentIds as $id) {
$this->_searchIndex->delete($id);
}
return $this;
}
示例5: delete
/**
* Deletes a document from the index.
* $id is an internal document id
*
* @param integer|Zend_Search_Lucene_Search_QueryHit $id
* @throws Zend_Search_Lucene_Exception
*/
public function delete($id)
{
return $this->_index->delete($id);
}