本文整理汇总了PHP中Zend_Search_Lucene::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene::delete方法的具体用法?PHP Zend_Search_Lucene::delete怎么用?PHP Zend_Search_Lucene::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene
的用法示例。
在下文中一共展示了Zend_Search_Lucene::delete方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: del
public function del($field, $id)
{
$index = new Zend_Search_Lucene(ZY_ROOT . '/index');
$keywords = $field . ":" . $id;
$hits = $index->find($keywords);
foreach ($hits as $hit) {
$index->delete($hit->id);
}
$index->commit();
return TRUE;
}
示例2: deleteDocument
/**
* Removes a document from the index.
*
* @param int $docid
* @return array containing (content, discussion, title)
*/
public function deleteDocument($docid)
{
$content = '';
$discussion = '';
$query = Zend_Search_Lucene_Search_QueryParser::parse('DocumentID:' . PHPLuceneIndexer::longToString($docid));
$hits = $this->lucene->find($query);
// there should only be one, but we'll loop for safety
foreach ($hits as $hit) {
$content = $hit->Content;
$discussion = $hit->Discussion;
$title = $hit->Title;
$version = $hit->Version;
$this->lucene->delete($hit);
}
return array($content, $discussion, $title, $version);
}
示例3: removeFromIndex
/**
* removeFromIndex
* @param string $strIndexPath
* @param string $strKey
* @author Thomas Schedler <tsh@massiveart.com>
* @version 1.0
*/
protected final function removeFromIndex($strIndexPath, $strKey)
{
try {
if (count(scandir($strIndexPath)) > 2) {
$this->objIndex = Zend_Search_Lucene::open($strIndexPath);
$objTerm = new Zend_Search_Lucene_Index_Term($strKey, 'key');
$objQuery = new Zend_Search_Lucene_Search_Query_Term($objTerm);
$objHits = $this->objIndex->find($objQuery);
foreach ($objHits as $objHit) {
$this->objIndex->delete($objHit->id);
}
$this->objIndex->commit();
$this->objIndex->optimize();
}
} catch (Exception $exc) {
$this->core->logger->err($exc);
}
}
示例4: removeFromIndex
/**
* removeFromIndex
* @param string $strIndexPath
* @param string $strKey
* @author Thomas Schedler <tsh@massiveart.com>
* @version 1.0
*/
protected final function removeFromIndex($strIndexPath, $strKey)
{
try {
$this->core->logger->debug('massiveart->generic->data->types->GenericDataTypeAbstract->removeFromIndex(' . $strIndexPath . ', ' . $strKey . ')');
if (count(scandir($strIndexPath)) > 2) {
$this->objIndex = Zend_Search_Lucene::open($strIndexPath);
$objTerm = new Zend_Search_Lucene_Index_Term($strKey, 'key');
$objQuery = strpos($strKey, '*') !== false ? new Zend_Search_Lucene_Search_Query_Wildcard($objTerm) : new Zend_Search_Lucene_Search_Query_Term($objTerm);
$objHits = $this->objIndex->find($objQuery);
foreach ($objHits as $objHit) {
$this->objIndex->delete($objHit->id);
}
$this->objIndex->commit();
$this->objIndex->optimize();
}
} catch (Exception $exc) {
$this->core->logger->err($exc);
}
}
示例5: foreach
$records = get_records_sql($query);
if (is_array($records)) {
foreach ($records as $record) {
$updates[] = $delete_function($record->docid, $docIds[$record->docid]);
}
}
}
foreach ($updates as $update) {
++$update_count;
//delete old document
$doc = $index->find("+docid:{$update->id} +doctype:{$mod->name} +itemtype:{$update->itemtype}");
//get the record, should only be one
foreach ($doc as $thisdoc) {
mtrace(" Delete: {$thisdoc->title} (database id = {$thisdoc->dbid}, index id = {$thisdoc->id}, moodle instance id = {$thisdoc->docid})");
$dbcontrol->delDocument($thisdoc);
$index->delete($thisdoc->id);
}
//add new modified document back into index
if (!($add = $get_document_function($update->id, $update->itemtype))) {
// ignore on errors
continue;
}
//object to insert into db
$dbid = $dbcontrol->addDocument($add);
//synchronise db with index
$add->addField(Zend_Search_Lucene_Field::Keyword('dbid', $dbid));
mtrace(" Add: {$add->title} (database id = {$add->dbid}, moodle instance id = {$add->docid})");
$index->addDocument($add);
}
} else {
mtrace("No types to update.\n");
示例6: deleteHit
/**
* Delete a hit. This can be useful for dynamically purging stuff.
*/
public function deleteHit($hit)
{
$this->index->delete($hit->id);
}
示例7: updateEntryInSearch
private function updateEntryInSearch($url, array $content = null)
{
$options = $this->getInvokeArg('bootstrap')->getOption('lucene');
$index = new Zend_Search_Lucene($options['dir']);
$hits = $index->find('url:' . $url);
foreach ($hits as $hit) {
$index->delete($hit->id);
}
if (!$content) {
return;
} else {
$this->addEntryToSearchIndex($url, $content);
}
}
示例8: RefreshSearchIndex
/**
* This will refresh the search index for this topic (for all message content under this topic)
* @param Zend_Search_Lucene $objIndex should be null if we are updating just one -- but for bulk index updates, you can pass in an already loaded index file
* @return void
*/
public function RefreshSearchIndex($objIndex = null)
{
// Currently only implemented for Forum-based topic/message searches
if ($this->TopicLink->TopicLinkTypeId != TopicLinkType::Forum) {
return;
}
if (!$objIndex) {
$objIndex = new Zend_Search_Lucene(__SEARCH_INDEXES__ . '/topics');
$blnIndexProvided = false;
} else {
$blnIndexProvided = true;
}
// Retrievew the Index Documents (if applicable) to delete them from the index
$objSearchTerm = new Zend_Search_Lucene_Index_Term($this->Id, 'db_id');
foreach ($objIndex->termDocs($objSearchTerm) as $intDocId) {
$objIndex->delete($intDocId);
}
// Create the Message Contents for this Topic
$strContents = null;
foreach ($this->GetMessageArray(QQ::OrderBy(QQN::Message()->ReplyNumber)) as $objMessage) {
$strMessage = strip_tags(trim($objMessage->CompiledHtml));
$strMessage = html_entity_decode($strMessage, ENT_QUOTES, 'UTF-8');
$strContents .= $strMessage . "\r\n\r\n";
}
// Create the Document
$objDocument = new Zend_Search_Lucene_Document();
$objDocument->addField(Zend_Search_Lucene_Field::Keyword('db_id', $this->Id));
$objDocument->addField(Zend_Search_Lucene_Field::UnIndexed('topic_link_id', $this->TopicLinkId));
$objDocument->addField(Zend_Search_Lucene_Field::UnIndexed('topic_link_type_id', $this->TopicLink->TopicLinkTypeId));
$objDocument->addField(Zend_Search_Lucene_Field::UnIndexed('message_count', $this->MessageCount));
$objDocument->addField(Zend_Search_Lucene_Field::UnIndexed('last_post_date', $this->LastPostDate->Timestamp));
$objDocument->addField(Zend_Search_Lucene_Field::Text('title', $this->Name));
$objDocument->addField(Zend_Search_Lucene_Field::UnStored('contents', trim($strContents)));
// Add Document to Index
$objIndex->addDocument($objDocument);
// Only call commit on the index if it was provided for us
if (!$blnIndexProvided) {
$objIndex->commit();
}
}