本文整理汇总了PHP中Zend_Search_Lucene_Field类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Field类的具体用法?PHP Zend_Search_Lucene_Field怎么用?PHP Zend_Search_Lucene_Field使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Search_Lucene_Field类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: index_lucene
function index_lucene($article, $optimise)
{
$index = getIndex_lucene();
$term = new Zend_Search_Lucene_Index_Term($article["PMID"], 'PMID');
// a pre-existing page cannot be updated, it has to be
// deleted, and indexed again:
$exactSearchQuery = new Zend_Search_Lucene_Search_Query_Term($term);
$hits = $index->find($exactSearchQuery);
if (count($hits) > 0) {
echo "[deleting previous version]\n";
foreach ($hits as $hit) {
$index->delete($hit->id);
}
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('PMID', $article["PMID"]));
$doc->addField(Zend_Search_Lucene_Field::Keyword('Year', $article["Year"]));
$doc->addField(Zend_Search_Lucene_Field::Keyword('Journal', $article["Journal"]));
$doc->addField(Zend_Search_Lucene_Field::Text('Title', $article["Title"], 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('Authors', $article["Authors"], 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('Reference', $article["Reference"], 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnStored('Abstract', $article["Abstract"], 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('MeshHeadings', $article["MeshHeadings"], 'utf-8'));
$index->addDocument($doc);
if ($optimise) {
echo "Optimising index\n";
$index->optimize();
}
$index->commit();
echo "The index contains " . $index->numDocs() . " documents\n";
}
开发者ID:jbpoline,项目名称:brainspell,代码行数:31,代码来源:admin-upload-papers.php
示例2: update
public static function update($data)
{
try {
//Update an index.
$index = Zend_Search_Lucene::open('../application/searchindex');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
} catch (Zend_Search_Exception $e) {
throw $e;
}
// remove an existing entry
$hits = $index->find('pk:' . $data['pk']);
foreach ($hits as $hit) {
$index->delete($hit->id);
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $data['pk']));
$doc->addField(Zend_Search_Lucene_Field::Keyword('code', $data['code'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Keyword('u_code', strtolower($data['code']), 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::unIndexed('type', $data['type'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::unIndexed('id', $data['id'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', $data['title'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('en_title', Default_Model_Functions::convert_vi_to_en($data['title']), 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('description', $data['description'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('en_description', Default_Model_Functions::convert_vi_to_en($data['description']), 'UTF-8'));
$index->addDocument($doc);
$index->commit();
}
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:27,代码来源:LuceneIndex.php
示例3: edit
public function edit($needFields = array(), $data = array(), $charset = 'UTF-8')
{
$index = new Zend_Search_Lucene(ZY_ROOT . '/index');
$doc = new Zend_Search_Lucene_Document();
foreach ($needFields as $key => $field) {
switch ($field) {
case 'keywords':
$doc->addField(Zend_Search_Lucene_Field::Keyword($key, $data[$key], $charset));
break;
case 'text':
$doc->addField(Zend_Search_Lucene_Field::Text($key, $data[$key], $charset));
break;
case 'unindexed':
$doc->addField(Zend_Search_Lucene_Field::unindexed($key, $data[$key], $charset));
break;
default:
$doc->addField(Zend_Search_Lucene_Field::$field($key, $data[$key], $charset));
break;
}
}
$index->addDocument($doc);
$index->commit();
$index->optimize();
return TRUE;
}
开发者ID:BGCX262,项目名称:zyshop-svn-to-git,代码行数:25,代码来源:search_lucnene.php
示例4: luceneIndexAction
public function luceneIndexAction()
{
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$path = PUBLIC_PATH . '/tmp/lucene';
try {
$index = Zend_Search_Lucene::open($path);
} catch (Zend_Search_Lucene_Exception $e) {
try {
$index = Zend_Search_Lucene::create($path);
} catch (Zend_Search_Lucene_Exception $e) {
echo "Unable to open or create index : {$e->getMessage()}";
}
}
for ($i = 0; $i < $index->maxDoc(); $i++) {
$index->delete($i);
}
$users = new Application_Model_User();
$users = $users->fetchAll();
foreach ($users as $_user) {
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('title', $_user->getFirstName()));
$doc->addField(Zend_Search_Lucene_Field::keyword('empcode', $_user->getEmployeeCode()));
$index->addDocument($doc);
$index->commit();
$index->optimize();
}
}
开发者ID:riteshsahu1981,项目名称:we,代码行数:29,代码来源:ImageController.php
示例5: updateLuceneIndex
public function updateLuceneIndex()
{
//delete existing entries
$index = $this->getTable()->getLuceneIndex();
// remove existing entries
foreach ($index->find('pk:' . $this->getId()) as $hit) {
$index->delete($hit->id);
}
// create new Lucene document
$doc = new Zend_Search_Lucene_Document();
// store product primary key to identify it in the search results
$doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId()));
$tr = Doctrine::getTable('ProductTranslation')->createQuery()->from('ProductTranslation pt')->where('pt.id = ?', $this->getId())->execute();
$doc->addField(Zend_Search_Lucene_Field::UnStored('original_title', $this->getOriginalTitle(), 'utf-8'));
// add fields to index depending on existing Translations
foreach ($tr->toArray() as $transArr) {
$lang = $transArr['lang'];
unset($transArr['lang'], $transArr['id'], $transArr['volume'], $transArr['slug']);
foreach ($transArr as $field => $value) {
$fieldName = $field . '_' . $lang;
// (name_en, name_fi), (description_en, description_fi)
$doc->addField(Zend_Search_Lucene_Field::UnStored($fieldName, strip_tags($value), 'utf-8'));
}
}
// add product to the index
$index->addDocument($doc);
$index->commit();
}
开发者ID:vcgato29,项目名称:poff,代码行数:28,代码来源:Product.class.php
示例6: makeDoc
/**
* Construct a Zend_Search_Lucene_Document object out of a document db row.
*
* @global string $urlServer
* @param object $docu
* @return Zend_Search_Lucene_Document
*/
protected function makeDoc($docu) {
global $urlServer;
$encoding = 'utf-8';
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('pk', 'doc_' . $docu->id, $encoding));
$doc->addField(Zend_Search_Lucene_Field::Keyword('pkid', $docu->id, $encoding));
$doc->addField(Zend_Search_Lucene_Field::Keyword('doctype', 'doc', $encoding));
$doc->addField(Zend_Search_Lucene_Field::Keyword('courseid', $docu->course_id, $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('title', Indexer::phonetics($docu->title), $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('content', Indexer::phonetics($docu->description), $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('filename', Indexer::phonetics($docu->filename), $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('comment', Indexer::phonetics($docu->comment), $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('creator', Indexer::phonetics($docu->creator), $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('subject', Indexer::phonetics($docu->subject), $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('author', Indexer::phonetics($docu->author), $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('visible', $docu->visible, $encoding));
$doc->addField(Zend_Search_Lucene_Field::Text('public', $docu->public, $encoding));
$urlAction = ($docu->format == '.dir') ? 'openDir' : 'download';
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('url', $urlServer
. 'modules/document/index.php?course=' . course_id_to_code($docu->course_id)
. '&' . $urlAction . '=' . $docu->path, $encoding));
return $doc;
}
开发者ID:nikosv,项目名称:openeclass,代码行数:33,代码来源:documentindexer.class.php
示例7: 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();
}
开发者ID:neolao,项目名称:wiki,代码行数:33,代码来源:Search.php
示例8: __construct
private function __construct($rule, $additional, $storeContent)
{
/*$dom = new DOMDocument ();
$dom->preserveWhiteSpace = false;
$dom->loadXML ( $rule );*/
//walk through the association rule and index it
//$this->_parse ( $rule, 1 );
$quantifiers = $rule->childNodes;
foreach ($quantifiers as $quantifier) {
if ($quantifier->nodeName == '#text' || $quantifier->nodeValue == '') {
continue;
}
//print $quantifier->nodeName.' : '. trim($quantifier->nodeValue).'<br/>';
$val = trim($quantifier->nodeValue);
if (is_numeric($val)) {
$val = JuceneHelper::prepareNumber($val);
} else {
$val = (string) $val;
$val = str_replace("-", "", $val);
}
if ($quantifier->nodeName == 'Text') {
$type = 'Unindexed';
} else {
$type = 'Text';
}
$this->addField(Zend_Search_Lucene_Field::$type($quantifier->nodeName, $val, JUCENE_ENCODING));
}
foreach ($additional as $field => $value) {
if (is_numeric($value)) {
$val = JuceneHelper::prepareNumber($value);
}
$this->addField(Zend_Search_Lucene_Field::Keyword('service_' . $field, $value, JUCENE_ENCODING));
}
}
开发者ID:KIZI,项目名称:sewebar-cms,代码行数:34,代码来源:Pmml.php
示例9: buildAction
public function buildAction()
{
// create the index
$index = Zend_Search_Lucene::create(APPLICATION_PATH . '/indexes');
// fetch all of the current pages
$mdlPage = new Model_Page();
$currentPages = $mdlPage->fetchAll();
if ($currentPages->count() > 0) {
// create a new search document for each page
foreach ($currentPages as $p) {
$page = new CMS_Content_Item_Page($p->id);
$doc = new Zend_Search_Lucene_Document();
// you use an unindexed field for the id because you want the id to be
// included in the search results but not searchable
$doc->addField(Zend_Search_Lucene_Field::unIndexed('page_id', $page->id));
// you use text fields here because you want the content to be searchable
// and to be returned in search results
$doc->addField(Zend_Search_Lucene_Field::text('page_name', $page->name));
$doc->addField(Zend_Search_Lucene_Field::text('page_headline', $page->headline));
$doc->addField(Zend_Search_Lucene_Field::text('page_description', $page->description));
$doc->addField(Zend_Search_Lucene_Field::text('page_content', $page->content));
// add the document to the index
$index->addDocument($doc);
}
}
// optimize the index
$index->optimize();
// pass the view data for reporting
$this->view->indexSize = $index->numDocs();
}
开发者ID:mtaha1990,项目名称:onlineDR,代码行数:30,代码来源:SearchController.php
示例10: _indexate
protected function _indexate($url)
{
if (!stristr($url, 'http://')) {
$url = HTTP_HOST . $url;
}
$url = substr($url, -1) == '/' ? substr($url, 0, -1) : $url;
if (!in_array($url, $this->_indexedUrl)) {
if (stristr($url, HTTP_HOST)) {
array_push($this->_indexedUrl, $url);
$html = file_get_contents($url);
libxml_use_internal_errors(true);
$doc = Zend_Search_Lucene_Document_Html::loadHTML($html);
libxml_use_internal_errors(false);
if (preg_match('/<\\!--index-->(.*)<\\!--\\/index-->/isu', $html, $matches)) {
$html = $matches[1];
}
$html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $html);
$html = strip_tags($html);
$doc->addField(Zend_Search_Lucene_Field::Text('content', $html, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('body', '', 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('url', $url, 'utf-8'));
$this->_indexHandle->addDocument($doc);
Zend_Registry::get('Logger')->info('Search index is created: ' . $url, Zend_Log::INFO);
foreach ($doc->getLinks() as $link) {
$temp = explode('.', $link);
$ext = end($temp);
if ($link == $ext || in_array($ext, array('php', 'html', 'txt', 'htm'))) {
$this->_indexate($link);
}
}
}
}
}
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:33,代码来源:CronController.php
示例11: updateAction
public function updateAction()
{
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
// Создание индекса
$index = Zend_Search_Lucene::create(APPLICATION_ROOT . '/data/my-index');
$mediaMapper = new Media_Model_Mapper_Media();
$select = $mediaMapper->getDbTable()->select();
$select->where('deleted != ?', 1)->where('active != ?', 0)->where('category_id IN(?)', array(2, 3, 4))->order('timestamp DESC');
$mediaItems = $mediaMapper->fetchAll($select);
if (!empty($mediaItems)) {
foreach ($mediaItems as $mediaItem) {
$doc = new Zend_Search_Lucene_Document();
// Сохранение Name документа для того, чтобы идентифицировать его
// в результатах поиска
$doc->addField(Zend_Search_Lucene_Field::Text('title', strtolower($mediaItem->getName()), 'UTF-8'));
// Сохранение URL документа для того, чтобы идентифицировать его
// в результатах поиска
$doc->addField(Zend_Search_Lucene_Field::Text('url', '/media/' . $mediaItem->getFullPath(), 'UTF-8'));
// Сохранение Description документа для того, чтобы идентифицировать его
// в результатах поиска
// $doc->addField(Zend_Search_Lucene_Field::Text('description', strtolower($mediaItem->getSContent()),'UTF-8'));
// Индексирование keyWords содержимого документа
$doc->addField(Zend_Search_Lucene_Field::UnStored('keyword', strtolower($mediaItem->getMetaKeywords()), 'UTF-8'));
// Индексирование содержимого документа
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', strtolower($mediaItem->getContent()), 'UTF-8'));
// Добавление документа в индекс
$index->addDocument($doc);
}
}
}
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:30,代码来源:SearchIndexController.php
示例12: buildplaces
public function buildplaces()
{
ini_set('memory_limit', '1000M');
set_time_limit(0);
$time = time();
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
/**
* Create index
*/
$index = Zend_Search_Lucene::create($this->_indexPath);
/**
* Get all users
*/
$sql = $this->_db->select()->from($this->_name, array('id', 'name', 'placepic'))->limit(7500);
$result = $this->_db->fetchAssoc($sql);
foreach ($result as $values) {
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::keyword('placeid', $values['id']));
$doc->addField(Zend_Search_Lucene_Field::text('placename', $values['name']));
$doc->addField(Zend_Search_Lucene_Field::unStored('placepic', $values['placepic']));
$index->addDocument($doc);
}
$index->commit();
$elapsed = time() - $time;
print_r($elapsed);
}
开发者ID:abdulnizam,项目名称:zend-freniz,代码行数:26,代码来源:places.php
示例13: __construct
/**
* Object constructor
*
* @param string $data
* @param boolean $storeContent
*/
private function __construct($data, $storeContent)
{
try {
$zendpdf = \Zend_Pdf::parse($data);
// Store meta data properties
if (isset($zendpdf->properties['Title'])) {
$this->addField(\Zend_Search_Lucene_Field::UnStored('title', $zendpdf->properties['Title']));
}
if (isset($zendpdf->properties['Author'])) {
$this->addField(\Zend_Search_Lucene_Field::UnStored('author', $zendpdf->properties['Author']));
}
if (isset($zendpdf->properties['Subject'])) {
$this->addField(\Zend_Search_Lucene_Field::UnStored('subject', $zendpdf->properties['Subject']));
}
if (isset($zendpdf->properties['Keywords'])) {
$this->addField(\Zend_Search_Lucene_Field::UnStored('keywords', $zendpdf->properties['Keywords']));
}
//TODO handle PDF 1.6 metadata Zend_Pdf::getMetadata()
//do the content extraction
$pdfParse = new \App_Search_Helper_PdfParser();
$body = $pdfParse->pdf2txt($zendpdf->render());
if ($body != '') {
// Store contents
if ($storeContent) {
$this->addField(\Zend_Search_Lucene_Field::Text('body', $body, 'UTF-8'));
} else {
$this->addField(\Zend_Search_Lucene_Field::UnStored('body', $body, 'UTF-8'));
}
}
} catch (\Exception $e) {
Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), Util::ERROR);
}
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:39,代码来源:Pdf.php
示例14: IndexBug
public function IndexBug($bug)
{
$this->RemoveBug($bug->bug_id);
$doc = new Zend_Search_Lucene_Document();
$doc->AddField(Zend_Search_Lucene_Field::Keyword('bug_id', $bug->bug_id));
$doc->AddField(Zend_Search_Lucene_Field::Text('title', $bug->title));
$doc->AddField(Zend_Search_Lucene_Field::Keyword('reporting_user_id', $bug->reporting_user_id));
$doc->AddField(Zend_Search_Lucene_Field::Keyword('reporting_date', $bug->reporting_date));
// We concatenate all comments into a single text blob. We only show
// hits as bugs, but we want comment content to matter.
$comment_blob = '';
$stmt = Bugdar::$db->Prepare("SELECT body FROM " . TABLE_PREFIX . "comments WHERE bug_id = ? ORDER BY comment_id");
$stmt->Execute(array($bug->bug_id));
while ($comment = $stmt->FetchObject()) {
$comment_blob .= $comment->body . "\n\n";
}
$doc->AddField(Zend_Search_Lucene_Field::UnStored('comments', $comment_blob));
// Add all attributes.
$stmt = Bugdar::$db->Prepare("SELECT * FROM " . TABLE_PREFIX . "bug_attributes WHERE bug_id = ?");
$stmt->Execute(array($bug->bug_id));
$tags = array();
while ($attr = $stmt->FetchObject()) {
if ($attr->attribute_title) {
$doc->AddField(Zend_Search_Lucene_Field::Keyword($attr->attribute_title, $attr->value));
} else {
$tags[] = $attr->value;
}
}
$doc->AddField(Zend_Search_Lucene_Field::Text('tag', implode(' ', $tags)));
$this->lucene->AddDocument($doc);
}
开发者ID:rsesek,项目名称:Bugdar2,代码行数:31,代码来源:search_engine.php
示例15: actionIndexing
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndexing()
{
ini_set('max_execution_time', 0);
ob_start();
$index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
$criteria = new CDbCriteria();
$criteria->compare('t.publish', 1);
$criteria->order = 'album_id DESC';
//$criteria->limit = 10;
$model = Albums::model()->findAll($criteria);
foreach ($model as $key => $item) {
if ($item->media_id != 0) {
$images = Yii::app()->request->baseUrl . '/public/album/' . $item->album_id . '/' . $item->cover->media;
} else {
$images = '';
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->album_id), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('album/site/view', array('id' => $item->album_id, 't' => Utility::getUrlTitle($item->title)))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->creation_date, true) . ' WIB'), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
$index->addDocument($doc);
}
echo 'Album Lucene index created';
$index->commit();
$this->redirect(Yii::app()->createUrl('article/search/indexing'));
ob_end_flush();
}
开发者ID:OmmuOpenSource,项目名称:OOS-Company-Profile,代码行数:35,代码来源:SearchController.php
示例16: testAddFieldMethodChaining
public function testAddFieldMethodChaining()
{
$document = new Zend_Search_Lucene_Document();
$this->assertTrue($document->addField(Zend_Search_Lucene_Field::Text('title', 'Title')) instanceof Zend_Search_Lucene_Document);
$document = new Zend_Search_Lucene_Document();
$document->addField(Zend_Search_Lucene_Field::Text('title', 'Title'))->addField(Zend_Search_Lucene_Field::Text('annotation', 'Annotation'))->addField(Zend_Search_Lucene_Field::Text('body', 'Document body, document body, document body...'));
}
开发者ID:lortnus,项目名称:zf1,代码行数:7,代码来源:DocumentTest.php
示例17: index
function index()
{
$this->load->library('zend', 'Zend/Feed');
$this->load->library('zend', 'Zend/Search/Lucene');
$this->load->library('zend');
$this->zend->load('Zend/Feed');
$this->zend->load('Zend/Search/Lucene');
//Create index.
$index = new Zend_Search_Lucene('C:\\xampp\\xampp\\htdocs\\controle_frota\\lucene\\feeds_index', true);
$feeds = array('http://oglobo.globo.com/rss.xml?limite=50');
//grab each feed.
foreach ($feeds as $feed) {
$channel = Zend_Feed::import($feed);
echo $channel->title() . '<br />';
//index each item.
foreach ($channel->items as $item) {
if ($item->link() && $item->title() && $item->description()) {
//create an index doc.
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('link', $this->sanitize($item->link())));
$doc->addField(Zend_Search_Lucene_Field::Text('title', $this->sanitize($item->title())));
$doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $this->sanitize($item->description())));
echo "\tAdding: " . $item->title() . '<br />';
$index->addDocument($doc);
}
}
}
$index->commit();
echo $index->count() . ' Documents indexed.<br />';
}
开发者ID:ramonsilvanet,项目名称:controle-frota-php,代码行数:30,代码来源:pesquisas.php
示例18: __construct
public function __construct(Storefront_Resource_Product_Item_Interface $item, $category)
{
$this->addField(Zend_Search_Lucene_Field::keyword('productId', $item->productId, 'UTF-8'));
$this->addField(Zend_Search_Lucene_Field::text('categories', $category, 'UTF-8'));
$this->addField(Zend_Search_Lucene_Field::text('name', $item->name, 'UTF-8'));
$this->addField(Zend_Search_Lucene_Field::unStored('description', $item->description, 'UTF-8'));
$this->addField(Zend_Search_Lucene_Field::text('price', $this->_formatPrice($item->getPrice()), 'UTF-8'));
}
开发者ID:AkimBolushbek,项目名称:zendframeworkstorefront,代码行数:8,代码来源:Product.php
示例19: testEncoding
public function testEncoding()
{
$field = Zend_Search_Lucene_Field::Text('field', 'Words with umlauts: εγό...', 'ISO-8859-1');
$this->assertEquals($field->encoding, 'ISO-8859-1');
$this->assertEquals($field->name, 'field');
$this->assertEquals($field->value, 'Words with umlauts: εγό...');
$this->assertEquals($field->getUtf8Value(), 'Words with umlauts: Γ₯ãü...');
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:8,代码来源:FieldTest.php
示例20: updateIndex
/**
* Updates the index for an object
*
* @param Doctrine_Record $object
*/
public function updateIndex(Doctrine_Record $object, $delete = false)
{
/* error checking */
if (!array_key_exists('models', $this->config) || empty($this->config['models'])) {
throw new Exception(sprintf('No models set in search.yml', $name));
}
if (!array_key_exists($model = get_class($object), $this->config['models'])) {
throw new Exception(sprintf('Model "%s" not defined in "%s" index in your search.yml', $model, $this->name));
}
$id = $this->generateId($object->getId(), $model);
$config = $this->config['models'][$model];
//delete existing entries
foreach ($this->search('_id:"' . $id . '"') as $hit) {
$this->getIndex()->delete($hit->id);
}
if ($delete) {
return;
}
//only add to search if canSearch method on model returns true (search if no method exists)
if (method_exists($object, 'canSearch')) {
if (!call_user_func(array($object, 'canSearch'))) {
return;
}
}
$doc = new Zend_Search_Lucene_Document();
// store a key for deleting in future
$doc->addField(Zend_Search_Lucene_Field::Keyword('_id', $id));
// store job primary key and model name to identify it in the search results
$doc->addField(Zend_Search_Lucene_Field::Keyword('_pk', $object->getId()));
$doc->addField(Zend_Search_Lucene_Field::Keyword('_model', $model));
// store title - used for search result title
if (!array_key_exists('title', $config)) {
throw new Exception(sprintf('A title must be set for model "%s" in search.yml', $model));
}
$doc->addField(Zend_Search_Lucene_Field::unIndexed('_title', call_user_func(array($object, 'get' . sfInflector::camelize($config['title'])))));
// store description - used for search result description
if (!array_key_exists('description', $config)) {
throw new Exception(sprintf('A description must be set for model "%s" in search.yml', $model));
}
$doc->addField(Zend_Search_Lucene_Field::unIndexed('_description', call_user_func(array($object, 'get' . sfInflector::camelize($config['description'])))));
// store url - @todo add more routing options
if (!array_key_exists('route', $config)) {
throw new Exception(sprintf('A route must be set for model "%s" in search.yml', $model));
}
sfContext::getInstance()->getConfiguration()->loadHelpers('Url');
$url = url_for($config['route'], $object);
$doc->addField(Zend_Search_Lucene_Field::unIndexed('_url', $url));
//store fields
if (array_key_exists('fields', $config)) {
foreach ($config['fields'] as $field => $config) {
$doc->addField(Zend_Search_Lucene_Field::UnStored($field, call_user_func(array($object, 'get' . sfInflector::camelize($field))), 'utf-8'));
}
}
//save index
$this->getIndex()->addDocument($doc);
$this->getIndex()->commit();
}
开发者ID:kbond,项目名称:zsUtilPlugin,代码行数:62,代码来源:zsSearchIndex.class.php
注:本文中的Zend_Search_Lucene_Field类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论