本文整理汇总了PHP中Zend_Search_Lucene类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene类的具体用法?PHP Zend_Search_Lucene怎么用?PHP Zend_Search_Lucene使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Search_Lucene类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: search
public function search($keywords, $charset = 'utf-8')
{
$index = new Zend_Search_Lucene(ZY_ROOT . '/index');
$query = Zend_Search_Lucene_Search_QueryParser::parse($keywords, $charset);
$hits = $index->find($query);
return $hits;
}
开发者ID:BGCX262,项目名称:zyshop-svn-to-git,代码行数:7,代码来源:search_lucnene.php
示例2: getDocument
/**
* Return the document object for this hit
*
* @return Zend_Search_Lucene_Document
*/
public function getDocument()
{
if (!$this->_document instanceof Zend_Search_Lucene_Document) {
$this->_document = $this->_index->getDocument($this->id);
}
return $this->_document;
}
开发者ID:Nurudeen,项目名称:prado,代码行数:12,代码来源:QueryHit.php
示例3: onSearchLucene
function onSearchLucene($text, $phrase = '', $ordering = '', $areas = null)
{
if (is_array($areas) && count($areas) > 0) {
if (!array_intersect($areas, array_keys($this->areas))) {
return array();
}
} else {
if (count($areas) == 0) {
$areas = array();
foreach ($this->areas as $k => $v) {
$areas[] = $k;
}
}
}
$results = array();
$params = JComponentHelper::getParams('com_search_lucene');
$indexpath = $params->get('indexpath');
$pluginindex = $indexpath . DS . $this->pluginName;
$index = new Zend_Search_Lucene($pluginindex);
$search = '(';
foreach ($areas as $area) {
if (array_key_exists($area, $this->areas)) {
$search .= ' type:' . $area;
}
}
$search .= ')';
if ($index && strlen($text) > 3) {
$rows = $index->find($text . ' AND ' . $search);
} else {
$rows = array();
}
return $rows;
}
开发者ID:beingsane,项目名称:com-search-lucene,代码行数:33,代码来源:search_lucene_extend.php
示例4: __construct
public function __construct($path = SEARCH_INDEX_PATH)
{
global $CFG, $db;
$this->path = $path;
//test to see if there is a valid index on disk, at the specified path
try {
$test_index = new Zend_Search_Lucene($this->path, false);
$validindex = true;
} catch (Exception $e) {
$validindex = false;
}
//retrieve file system info about the index if it is valid
if ($validindex) {
$this->size = display_size(get_directory_size($this->path));
$index_dir = get_directory_list($this->path, '', false, false);
$this->filecount = count($index_dir);
$this->indexcount = $test_index->count();
} else {
$this->size = 0;
$this->filecount = 0;
$this->indexcount = 0;
}
$db_exists = false;
//for now
//get all the current tables in moodle
$admin_tables = $db->MetaTables();
//TODO: use new IndexDBControl class for database checks?
//check if our search table exists
if (in_array($CFG->prefix . SEARCH_DATABASE_TABLE, $admin_tables)) {
//retrieve database information if it does
$db_exists = true;
//total documents
$this->dbcount = count_records(SEARCH_DATABASE_TABLE);
//individual document types
// $types = search_get_document_types();
$types = search_collect_searchables(true, false);
sort($types);
foreach ($types as $type) {
$c = count_records(SEARCH_DATABASE_TABLE, 'doctype', $type);
$this->types[$type] = (int) $c;
}
} else {
$this->dbcount = 0;
$this->types = array();
}
//check if the busy flag is set
if (isset($CFG->search_indexer_busy) && $CFG->search_indexer_busy == '1') {
$this->complete = false;
} else {
$this->complete = true;
}
//get the last run date for the indexer
if ($this->valid() && $CFG->search_indexer_run_date) {
$this->time = $CFG->search_indexer_run_date;
} else {
$this->time = 0;
}
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:58,代码来源:indexlib.php
示例5: search
private function search($terms)
{
Yii::import('application.vendor.*');
require_once 'Zend/Search/Lucene.php';
$index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.index'));
$result = $index->find($terms);
$query = Zend_Search_Lucene_Search_QueryParser::parse($terms);
return $result;
}
开发者ID:httvncoder,项目名称:tugastkilucene,代码行数:9,代码来源:SearchController.php
示例6: generateSitemap
public function generateSitemap()
{
$this->prepareSiteMapFolder();
if (!is_null($this->sitemapDir)) {
$hosts = $this->getValidHosts();
if (is_array($hosts)) {
foreach ($hosts as $hostName) {
$query = new \Zend_Search_Lucene_Search_Query_Boolean();
$hostTerm = new \Zend_Search_Lucene_Index_Term($hostName, 'host');
$hostQuery = new \Zend_Search_Lucene_Search_Query_Term($hostTerm);
$query->addSubquery($hostQuery, TRUE);
$hostTerm = new \Zend_Search_Lucene_Index_Term(TRUE, 'restrictionGroup_default');
$hostQuery = new \Zend_Search_Lucene_Search_Query_Term($hostTerm);
$query->addSubquery($hostQuery, TRUE);
$hits = $this->index->find($query);
$name = str_replace('.', '-', $hostName);
$filePath = $this->sitemapDir . '/sitemap-' . $name . '.xml';
$fh = fopen($filePath, 'w');
fwrite($fh, '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n");
fwrite($fh, '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
fwrite($fh, "\r\n");
for ($i = 0; $i < count($hits); $i++) {
$url = $hits[$i]->getDocument()->getField('url');
$uri = str_replace(array('?pimcore_outputfilters_disabled=1', '&pimcore_outputfilters_disabled=1'), '', $url->value);
fwrite($fh, '<url>' . "\r\n");
fwrite($fh, ' <loc>' . htmlspecialchars($uri, ENT_QUOTES) . '</loc>' . "\r\n");
fwrite($fh, '</url>' . "\r\n");
}
fwrite($fh, '</urlset>' . "\r\n");
fclose($fh);
}
$filePath = $this->sitemapDir . '/sitemap.xml';
$fh = fopen($filePath, 'w');
fwrite($fh, '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n");
fwrite($fh, '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
fwrite($fh, "\r\n");
foreach ($hosts as $hostName) {
$name = str_replace('.', '-', $hostName);
//first host must be main domain - see hint in plugin settings
$currenthost = $hosts[0];
fwrite($fh, '<sitemap>' . "\r\n");
fwrite($fh, ' <loc>http://' . $currenthost . '/plugin/LuceneSearch/frontend/sitemap/?sitemap=sitemap-' . $name . '.xml' . '</loc>' . "\r\n");
fwrite($fh, '</sitemap>' . "\r\n");
\Pimcore\Logger::debug('LuceneSearch: ' . $hostName . ' for sitemap.xml added.');
}
fwrite($fh, '</sitemapindex>' . "\r\n");
fclose($fh);
} else {
\Pimcore\Logger::debug('LuceneSearch: could not generate sitemaps, did not find any hosts in index.');
}
} else {
\Pimcore\Logger::emerg('LuceneSearch: Cannot generate sitemap. Sitemap directory [ ' . $this->sitemapDir . ' ] not available/not writeable and cannot be created');
}
}
开发者ID:dachcom-digital,项目名称:pimcore-lucene-search,代码行数:54,代码来源:SitemapBuilder.php
示例7: actionSearch
public function actionSearch()
{
//working.
$this->layout = 'column2';
if (($term = Yii::app()->getRequest()->getParam('q', null)) !== null) {
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
$index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles));
$results = $index->find($term);
$query = Zend_Search_Lucene_Search_QueryParser::parse($term);
$this->render('search', compact('results', 'term', 'query'));
}
}
开发者ID:EmmanuelFernando,项目名称:rapport-stock-control,代码行数:12,代码来源:SearchController.php
示例8: actionSearch
public function actionSearch()
{
$indexFiles = Yii::app()->getModule('zendsearch')->indexFiles;
SetLocale(LC_ALL, 'ru_RU.UTF-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
if (($term = Yii::app()->getRequest()->getQuery('q', null)) !== null) {
$index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $indexFiles));
$results = $index->find($term);
$query = Zend_Search_Lucene_Search_QueryParser::parse($term);
$this->render('search', compact('results', 'term', 'query'));
}
}
开发者ID:sepaker,项目名称:yupe,代码行数:13,代码来源:SearchController.php
示例9: fill_index
function fill_index()
{
for ($i = 0; $i < 10; $i++) {
$index = new Zend_Search_Lucene('./data/index', true);
$index->find("test");
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text("test", getword()));
$doc->addField(Zend_Search_Lucene_Field::UnStored("contents", getword()));
$index->addDocument($doc);
$index->commit();
$index->getDirectory()->close();
//comment this to see another bug :-|
}
}
开发者ID:Tony133,项目名称:zf-web,代码行数:14,代码来源:search_test.php
示例10: compact
$results = $index->find($term);
$query = Zend_Search_Lucene_Search_QueryParser::parse($term);
$this->render('/sParameter/search', compact('results', 'term', 'query'));
}
}
/**
* Search index creation
*/
public function actionCreate()
{
$index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles), true);
$posts = tAccount::model()->findAll();
foreach ($posts as $post) {
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('account_no', CHtml::encode($post->account_no), 'utf-8'));
开发者ID:kit9,项目名称:ERP_Accounting_Indonesia,代码行数:15,代码来源:_OLD_SearchController.php
示例11: search
function search($query)
{
$this->load->library('zend', 'Zend/Search/Lucene');
$this->load->library('zend');
$this->zend->load('Zend/Search/Lucene');
$index = new Zend_Search_Lucene('C:\\xampp\\xampp\\htdocs\\controle_frota\\lucene\\feeds_index');
$hits = $index->find($query);
echo 'Index contains ' . $index->count() . ' documents.<br /><br />';
echo 'Search for "' . $query . '" returned ' . count($hits) . ' hits<br /><br />';
foreach ($hits as $hit) {
echo $hit->title . '<br />';
echo 'Score: ' . sprintf('%.2f', $hit->score) . '<br />';
echo $hit->link . '<br /><br />';
}
}
开发者ID:ramonsilvanet,项目名称:controle-frota-php,代码行数:15,代码来源:pesquisas.php
示例12: getLucene
private function getLucene()
{
if ($this->lucene) {
return $this->lucene;
}
try {
$this->lucene = Zend_Search_Lucene::open($this->directory);
} catch (Zend_Search_Lucene_Exception $e) {
$this->lucene = Zend_Search_Lucene::create($this->directory);
}
global $prefs;
if (!empty($prefs['unified_lucene_max_buffered_docs'])) {
// these break indexing if set empty
$this->lucene->setMaxBufferedDocs($prefs['unified_lucene_max_buffered_docs']);
// default is 10
}
if (!empty($prefs['unified_lucene_max_merge_docs'])) {
$this->lucene->setMaxMergeDocs($prefs['unified_lucene_max_merge_docs']);
// default is PHP_INT_MAX (effectively "infinite")
}
if (!empty($prefs['unified_lucene_merge_factor'])) {
$this->lucene->setMergeFactor($prefs['unified_lucene_merge_factor']);
// default is 10
}
$this->lucene->setResultSetLimit($this->resultSetLimit);
return $this->lucene;
}
开发者ID:jkimdon,项目名称:cohomeals,代码行数:27,代码来源:Index.php
示例13: query
/**
* Enter description here...
*
* @param string $query
* @return array
*/
public function query($query)
{
$results = array();
$queryDiscussion = stripos($query, 'discussion') !== false;
$queryContent = stripos($query, 'content') !== false;
$query = Zend_Search_Lucene_Search_QueryParser::parse($query);
$hits = $this->lucene->find($query);
foreach ($hits as $hit) {
$document = $hit->getDocument();
$document_id = PHPLuceneIndexer::stringToLong($document->DocumentID);
$coreText = '';
if ($queryContent) {
$coreText .= $document->Content;
}
if ($queryDiscussion) {
$coreText .= $document->Discussion;
}
$content = $query->highlightMatches($coreText);
$title = $document->Title;
$score = $hit->score;
// avoid adding duplicates. If it is in already, it has higher priority.
if (!array_key_exists($document_id, $results) || $score > $results[$document_id]->Score) {
$item = new QueryResultItem($document_id, $score, $title, $content);
if ($item->CanBeReadByUser) {
$results[$document_id] = $item;
}
}
}
return $results;
}
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:36,代码来源:PHPLuceneIndexer.inc.php
示例14: initLuceneEngine
protected function initLuceneEngine()
{
$this->load->library('zend', 'Zend/Search/Lucene');
$this->load->library('zend');
$this->zend->load('Zend/Search/Lucene');
Zend_Search_Lucene::setDefaultSearchField('content');
}
开发者ID:cyberformed,项目名称:i2tree,代码行数:7,代码来源:search_engine_model.php
示例15: luceneSearchAction
public function luceneSearchAction()
{
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$path = PUBLIC_PATH . '/tmp/lucene';
$index = Zend_Search_Lucene::open($path);
// $term = new Zend_Search_Lucene_Index_Term('ritesh','title');
// $subquery1 = new Zend_Search_Lucene_Search_Query_Term($term);
//
// $from = new Zend_Search_Lucene_Index_Term('0', 'empcode');
// $to = new Zend_Search_Lucene_Index_Term('53', 'empcode');
// $subquery2 = new Zend_Search_Lucene_Search_Query_Range($from, $to, true);
//
// $query = new Zend_Search_Lucene_Search_Query_Boolean();
// $query->addSubquery($subquery1, true );
// $query->addSubquery($subquery2, null );
// Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
// $hits = $index->find($query);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(1);
$hits = $index->find("empcode:[000 TO 200]");
foreach ($hits as $h) {
echo "Title:" . $h->title;
echo "-------EmpCode:" . $h->empcode;
echo "<br>";
}
}
开发者ID:riteshsahu1981,项目名称:we,代码行数:27,代码来源:ImageController.php
示例16: 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
示例17: __construct
/**
* Creates a new ZendLucene handler connection
*
* @param string $location
*/
public function __construct($location)
{
/**
* We're using realpath here because Zend_Search_Lucene does not do
* that itself. It can cause issues because their destructor uses the
* same filename but the cwd could have been changed.
*/
$location = realpath($location);
/* If the $location doesn't exist, ZSL throws a *generic* exception. We
* don't care here though and just always assume it is because the
* index does not exist. If it doesn't exist, we create it.
*/
try {
$this->connection = Zend_Search_Lucene::open($location);
} catch (Zend_Search_Lucene_Exception $e) {
$this->connection = Zend_Search_Lucene::create($location);
}
$this->inTransaction = 0;
if (!$this->connection) {
throw new ezcSearchCanNotConnectException('zendlucene', $location);
}
// Set proper default encoding for query parser
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
}
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:30,代码来源:zend_lucene.php
示例18: searchAction
public function searchAction()
{
Zend_Registry::set('theaction', 'content');
$this->toTpl('theInclude', 'list');
Zend_Registry::set('module', 'Search Results');
//error_reporting(E_ALL);
$data = $this->_request->getParams();
if (trim($data['q'])) {
$dirs = $this->dirs;
$word = strtolower($data['q']);
$index = new Zend_Search_Lucene(APPL_PATH . $dirs['structure']['indexes'] . DIR_SEP . "objects");
$exp = explode(" ", $word);
$query = new Zend_Search_Lucene_Search_Query_Phrase($exp);
$query->setSlop(2);
//get all available indexed
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene::setResultSetLimit(10);
$result = $index->find($query);
foreach ($result as $hit) {
$obj = $this->getAllBySlug($hit->slug);
$type = $this->getContentType($obj['type_id']);
$content = $this->getContent($type['title'], $obj['id']);
$resu[] = $content;
}
$resu = $this->doQoolHook('front_pre_assign_search_results', $resu);
$this->toTpl('content', $resu);
} else {
$params = array("message" => $this->t("Please fill in a search term"), "msgtype" => 'error');
$this->addMessage($params);
$this->_helper->redirector('index', 'index', 'default');
}
}
开发者ID:basdog22,项目名称:Qool,代码行数:33,代码来源:IndexController.php
示例19: 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
示例20: buildPostSearch
/**
* Build the post search index
*
* @param boolean $isCount
* @return boolean
*/
protected function buildPostSearch($isCount = false)
{
$index = Zend_Search_Lucene::create(Zend_Registry::getInstance()->config->search->post);
require_once 'Ifphp/models/Posts.php';
require_once 'Ifphp/models/Feeds.php';
require_once 'Ifphp/models/Categories.php';
$posts = new Posts();
$allPosts = $posts->getRecent(1, 0);
if ($isCount) {
echo $allPosts->count() . ' posts would have been added to the post index';
exit;
}
foreach ($allPosts as $post) {
$feed = $post->findParentFeeds();
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('pid', $post->id));
$doc->addField(Zend_Search_Lucene_Field::Text('title', $post->title));
$doc->addField(Zend_Search_Lucene_Field::Text('siteUrl', $post->siteUrl));
$doc->addField(Zend_Search_Lucene_Field::Text('link', $post->link));
$doc->addField(Zend_Search_Lucene_Field::Text('feedTitle', $feed->title));
$doc->addField(Zend_Search_Lucene_Field::Text('feedSlug', $feed->slug));
$doc->addField(Zend_Search_Lucene_Field::Text('feedDescription', $feed->description));
$doc->addField(Zend_Search_Lucene_Field::keyword('category', $feed->findParentCategories()->title));
$doc->addField(Zend_Search_Lucene_Field::Text('description', $post->description));
$doc->addField(Zend_Search_Lucene_Field::unIndexed('publishDate', $post->publishDate));
$doc->addField(Zend_Search_Lucene_Field::Keyword('type', 'post'));
$index->addDocument($doc);
}
chown(Zend_Registry::getInstance()->search['post'], 'www-data');
return true;
}
开发者ID:aprondak,项目名称:ifphp,代码行数:37,代码来源:SearchProvider.php
注:本文中的Zend_Search_Lucene类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论