本文整理汇总了PHP中Zend_Search_Lucene::setResultSetLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene::setResultSetLimit方法的具体用法?PHP Zend_Search_Lucene::setResultSetLimit怎么用?PHP Zend_Search_Lucene::setResultSetLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene
的用法示例。
在下文中一共展示了Zend_Search_Lucene::setResultSetLimit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMatchingConnections
function getMatchingConnections($criteria)
{
$index = $this->getIndex();
Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(0);
Zend_Search_Lucene::setResultSetLimit(25);
// TODO during dev
$results = $index->find($criteria);
$ret = array();
foreach ($results as $hit) {
$res = array();
$res['created'] = $hit->created;
try {
$res['title'] = $hit->title;
} catch (Zend_Search_Lucene_Exception $e) {
$res['title'] = '';
}
try {
$res['url'] = $hit->url;
} catch (Zend_Search_Lucene_Exception $e) {
$res['url'] = '';
}
try {
$res['keywords'] = $hit->keywords;
} catch (Zend_Search_Lucene_Exception $e) {
$res['keywords'] = '';
}
try {
$res['language'] = $hit->language;
} catch (Zend_Search_Lucene_Exception $e) {
$res['language'] = '';
}
try {
$res['geo_lat'] = $hit->geo_lat;
} catch (Zend_Search_Lucene_Exception $e) {
$res['geo_lat'] = '';
}
try {
$res['geo_lon'] = $hit->geo_lon;
} catch (Zend_Search_Lucene_Exception $e) {
$res['geo_lon'] = '';
}
try {
$res['geo_zoom'] = $hit->geo_zoom;
} catch (Zend_Search_Lucene_Exception $e) {
$res['geo_zoom'] = '';
}
$res['class'] = 'tablename';
$res['metadata'] = '';
if ($res['geo_lat'] && $res['geo_lon']) {
$res['class'] .= ' geolocated connection';
$res['metadata'] = " data-geo-lat=\"{$res['geo_lat']}\" data-geo-lon=\"{$res['geo_lon']}\"";
if (isset($res['geo_zoom'])) {
$res['metadata'] .= " data-geo-zoom=\"{$res['geo_zoom']}\"";
}
$res['metadata'] .= ' data-icon-name="tiki"';
}
$ret[] = $res;
}
return $ret;
}
示例2: find
/**
* @param $queryString
* @return array
*/
public function find($queryString)
{
$queryString = trim($queryString);
if (empty($queryString)) {
return ["queryString" => $queryString, "message" => "No String"];
} else {
$index = \Zend_Search_Lucene::open($this->indexfile);
$res = explode(' ', $queryString);
\Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(1);
\Zend_Search_Lucene::setResultSetLimit(5);
$query = new \Zend_Search_Lucene_Search_Query_Boolean();
foreach ($res as $val) {
if (!empty($val)) {
$subquery = new \Zend_Search_Lucene_Search_Query_Boolean();
$searchkey1 = $val . "*";
$pattern = new \Zend_Search_Lucene_Index_Term($searchkey1, "name");
$userQuery = new \Zend_Search_Lucene_Search_Query_Wildcard($pattern);
$patternUsername = new \Zend_Search_Lucene_Index_Term($searchkey1, "username");
$usernameQuery = new \Zend_Search_Lucene_Search_Query_Wildcard($patternUsername);
$subquery->addSubquery($userQuery, null);
$subquery->addSubquery($usernameQuery, null);
$query->addSubquery($subquery, true);
}
}
$hits = $index->find($query);
if (!empty($hits)) {
$results = [];
foreach ($hits as $hit) {
if ($hit->username != $_SESSION['user']->username) {
$results[] = $hit->username;
}
}
if (!empty($results)) {
/** @noinspection PhpUndefinedMethodInspection */
/** @var Users $users */
$users = $_SESSION['user']->getTable();
if (isset($_POST['friends'])) {
/** @noinspection PhpUndefinedMethodInspection */
$friends = $_SESSION['user']->getFriendList();
if (empty($friends)) {
return ["queryString" => $queryString, "users" => []];
} else {
$userresult = $users->getSet($results, 'u.username');
}
} else {
$userresult = $users->getSet($results, "u.username", ["u.userid", "u.username", "u.name"]);
}
return ["queryString" => $queryString, "users" => $userresult->toArray()];
}
}
}
return ["queryString" => $queryString];
}
示例3: search
public function search($query, $limit = 'none')
{
$config = Zend_Registry::get('config');
try {
$index = Zend_Search_Lucene::open($config->app->search->workshopIndexPath);
} catch (Exception $e) {
$index = Zend_Search_Lucene::create($config->app->search->workshopIndexPath);
}
if ($limit != 'none') {
Zend_Search_Lucene::setResultSetLimit($limit);
}
return $index->find($query);
}
示例4: getIndex
/**
*
* @param $name
* index name can be specified
*/
function getIndex($name = NULL)
{
require_once 'Zend/Search/Lucene.php';
$index_path = JuceneHelper::getIndexPath($name);
if (!JFolder::exists($index_path)) {
JFolder::create($index_path);
$index = Zend_Search_Lucene::create($index_path);
} else {
try {
$index = Zend_Search_Lucene::open($index_path);
} catch (Exception $ex) {
echo $ex->getMessage();
}
}
$component = JComponentHelper::getComponent('com_jucene');
$params =& JComponentHelper::getParams($component->params);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num());
Zend_Search_Lucene::setResultSetLimit($params->get('resuls_limit', 100));
return $index;
}
示例5: performSearch
/**
* Perform a search query on the index
*/
public function performSearch()
{
try {
$index = Zend_Search_Lucene::open(self::get_index_location());
Zend_Search_Lucene::setResultSetLimit(100);
$query = new Zend_Search_Lucene_Search_Query_Boolean();
$term = Zend_Search_Lucene_Search_QueryParser::parse($this->getQuery());
$query->addSubquery($term, true);
if ($this->modules) {
$moduleQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
foreach ($this->modules as $module) {
$moduleQuery->addTerm(new Zend_Search_Lucene_Index_Term($module, 'Entity'));
}
$query->addSubquery($moduleQuery, true);
}
if ($this->versions) {
$versionQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
foreach ($this->versions as $version) {
$versionQuery->addTerm(new Zend_Search_Lucene_Index_Term($version, 'Version'));
}
$query->addSubquery($versionQuery, true);
}
$er = error_reporting();
error_reporting('E_ALL ^ E_NOTICE');
$this->results = $index->find($query);
error_reporting($er);
$this->totalResults = $index->numDocs();
} catch (Zend_Search_Lucene_Exception $e) {
user_error($e . '. Ensure you have run the rebuld task (/dev/tasks/RebuildLuceneDocsIndex)', E_USER_ERROR);
}
}
示例6: searchQuery
function searchQuery($query, $size = SEARCH_RESULTS_SIZE)
{
$index = searchGetIndex();
Zend_Search_Lucene::setResultSetLimit($size);
return $index->find($query);
}
示例7: __readData
private function __readData(&$model, $queryData)
{
$highlight = false;
if (isset($queryData['highlight']) && $queryData['highlight'] == true) {
$highlight = true;
}
$limit = 1000;
// The following 3 lines break pagination. And since I can't figure out how to make Zend Lucene support
// offset, we'll just have to get all the results for pagination to work.
//
// if (!empty($queryData['limit'])) {
// $limit = $queryData['limit'];
// }
$query = $this->__parseQuery($queryData);
Zend_Search_Lucene::setResultSetLimit($limit);
$hits = $this->__index->find($query);
$data = array();
foreach ($hits as $i => $hit) {
$fields = $this->__getFieldInfo($hit->getDocument());
$returnArray = array();
foreach ($fields as $field) {
if ($highlight && $field->isIndexed == 1) {
$returnArray[$field->name] = $query->htmlFragmentHighlightMatches($hit->{$field->name});
} else {
$returnArray[$field->name] = $hit->{$field->name};
}
}
$returnArray['id'] = $hit->id;
$returnArray['score'] = $hit->score;
$data[$i][$model->alias] = $returnArray;
}
return $data;
}
示例8: __construct
/**
* Indexer Constructor.
*
* @global type $webDir
*/
public function __construct()
{
global $webDir;
if (!get_config('enable_indexing')) {
return;
}
$index_path = $webDir . self::$_index_dir;
// Give read-writing permissions only for current user and group
Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0600);
// Utilize UTF-8 compatible text analyzer
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
try {
if (file_exists($index_path)) {
$this->__index = Zend_Search_Lucene::open($index_path);
// Open index
} else {
$this->__index = Zend_Search_Lucene::create($index_path);
// Create index
}
} catch (Zend_Search_Lucene_Exception $e) {
require_once 'fatal_error.php';
}
$this->__index->setFormatVersion(Zend_Search_Lucene::FORMAT_2_3);
// Set Index Format Version
Zend_Search_Lucene::setResultSetLimit(self::$_resultSetLimit);
// Set Result Set Limit
// write an .htaccess to prevent raw access to index files
$htaccess = $index_path . '/.htaccess';
if (!file_exists($htaccess)) {
$fd = fopen($htaccess, "w");
fwrite($fd, "deny from all\n");
fclose($fd);
}
if (!file_exists($index_path . '/index.php')) {
touch($index_path . '/index.php');
}
}
示例9: search
public static function search( $query, $subqueries = array()) {
$query = strtolower($query);
Loader::library('3rdparty/Zend/Search/Lucene');
Loader::library('3rdparty/StandardAnalyzer/Analyzer/Standard/English');
$index = new Zend_Search_Lucene(DIR_FILES_CACHE_PAGES);
$index->setResultSetLimit(200);
//Zend_Search_Lucene_Analysis_Analyzer::setDefault(new StandardAnalyzer_Analyzer_Standard_English());
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new StandardAnalyzer_Analyzer_Standard_English());
$queryModifiers=array();
$mainQuery = Zend_Search_Lucene_Search_QueryParser::parse($query, APP_CHARSET);
$query = new Zend_Search_Lucene_Search_Query_Boolean();
$query->addSubquery($mainQuery, true);
foreach($subqueries as $subQ) {
if( !is_array($subQ) || !isset( $subQ['query'] ) )
$subQuery = $subQ;
else $subQuery = $subQ['query'];
if( !is_array($subQ) || !isset($subQ['required']) )
$required=true;
else $required=$subQ['required'];
$query->addSubquery( $subQuery, $required );
}
$query = utf8_encode($query);
$resultsTmp = $index->find($query);
$results = array();
foreach($resultsTmp as $r)
$results[] = new IndexedSearchResult($r->cID, $r->cName, $r->cDescription, $r->score, $r->cPath, $r->cBody);
return $results;
}
示例10: search
/**
* search function
* searches the index
*
* @param mixed $Model
* @param mixed $query
* @param int $limit
* @param int $page
* @access public
* @return void
*/
function search(&$Model, $query, $limit = 20, $page = 1)
{
// open the index
if (!$this->open_index($Model)) {
return false;
}
try {
// set the default encoding
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
// zend search results limiting (We will use the LimitIterator)
// we can use it for some maximum value like 1000 if its likely that there could be more results
Zend_Search_Lucene::setResultSetLimit(1000);
// set the parser default operator to AND
Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(Zend_Search_Lucene_Search_QueryParser::B_AND);
// utf-8 num analyzer
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
// parse the query
$Query = Zend_Search_Lucene_Search_QueryParser::parse($query);
$Terms = $Query->getQueryTerms();
foreach ($Terms as $Term) {
$this->terms[] = $Term->text;
}
// do the search
$Hits = new ArrayObject($this->Index->find($Query));
} catch (Zend_Search_Lucene_Exception $e) {
$this->log("Zend_Search_Lucene error: " . $e->getMessage(), 'searchable');
}
$this->hits_count = count($Hits);
if (!count($Hits)) {
return null;
}
$Hits = new LimitIterator($Hits->getIterator(), ($page - 1) * $limit, $limit);
$results = array();
foreach ($Hits as $Hit) {
$Document = $Hit->getDocument();
$fields = $Document->getFieldNames();
$result = array();
foreach ($fields as $field) {
$result['Result'][$field] = $Document->{$field};
}
$results[] = $result;
}
return $results;
}
示例11: searchPagesByQuery
/**
* Search all pages that match the query.
*
* <code>
* //$query = '(pi AND groupe AND partner*) OR pi-groupe';
* $query = " travers projet ference coin";
* $options = array(
* 'searchBool' => true,
* 'searchBoolType' => 'AND',
* 'searchByMotif' => true,
* 'setMinPrefixLength'=> 0,
* 'getResultSetLimit' => 0,
* 'searchFields' => array(
* 0=> array('sortField'=>'Contents', 'sortType'=> SORT_STRING, 'sortOrder' => SORT_ASC),
* 1=> array('sortField'=>'Key', 'sortType'=> SORT_NUMERIC, 'sortOrder' => SORT_DESC)
* ),
* );
* $result = $this->container->get('pi_app_admin.manager.search_lucene')->searchPagesByQuery($query, $options);
* </code>
*
* @link http://framework.zend.com/manual/fr/zend.search.lucene.searching.html
* @link http://framework.zend.com/manual/fr/learning.lucene.queries.html
* @link http://framework.zend.com/manual/1.12/fr/zend.search.lucene.query-api.html
* @param string $query The search query index file
* @param array $options Options of the search query of the index file
* @return array All Etags from pages that match the query.
* @access public
*
* @author Etienne de Longeaux <etienne_delongeaux@hotmail.com>
* @since 2012-06-11
*/
public function searchPagesByQuery($query = "Key:*", $options = null, $locale = '')
{
try {
if (isset($options) && is_array($options) && count($options) >= 1) {
$options_values = array_map(function ($key, $value) {
if (in_array($value, array("true"))) {
return 1;
} elseif (in_array($value, array("false"))) {
return 0;
} elseif (!is_array($value) && preg_match_all("/[0-9]+/", $value, $nbrs, PREG_SET_ORDER)) {
return intval($value);
} else {
return $value;
}
}, array_keys($options), array_values($options));
$options = array_combine(array_keys($options), $options_values);
}
if (empty($query)) {
return null;
} else {
$query = $this->container->get('sfynx.tool.string_manager')->minusculesSansAccents($query);
}
if (empty($locale)) {
$locale = $this->container->get('request')->getLocale();
}
$options_default = array('searchBool' => true, 'searchBoolType' => 'OR', 'searchByMotif' => true, 'setMinPrefixLength' => 0, 'getResultSetLimit' => 0, 'searchFields' => '*', 'searchMaxResultByWord' => 5);
if (is_array($options)) {
$options = array_merge($options_default, $options);
} else {
$options = $options_default;
}
if ($options['searchBool']) {
$q_string = $this->container->get('sfynx.tool.string_manager')->cleanWhitespace($query);
$q_array = explode(' ', $q_string);
if ($options['searchByMotif']) {
$q_array = array_map(function ($value) {
return $value . '*';
}, array_values($q_array));
}
switch ($options['searchBoolType']) {
case 'OR':
$new_query = implode(' OR ', $q_array);
break;
case 'AND':
$new_query = implode(' AND ', $q_array);
break;
default:
break;
}
} else {
$new_query = $query;
}
// Open the index.
self::open($this->_indexPath);
// Set minimum prefix length.
\Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength($options['setMinPrefixLength']);
// Set result set limit.
\Zend_Search_Lucene::setResultSetLimit($options['getResultSetLimit']);
// Performs a query against the index.
if (is_array($options['searchFields']) && $query != "Key:*") {
$fields_vars = "\$hits = self::\$_index->find(\$new_query,";
$i = 0;
foreach ($options['searchFields'] as $key => $valuesField) {
$sortField = $valuesField["sortField"];
if (isset($valuesField["sortType"]) && !empty($valuesField["sortType"])) {
$sortType = $valuesField["sortType"];
} else {
$sortType = SORT_STRING;
}
//.........这里部分代码省略.........
示例12: search
/**
* Execute the query
*
* @param string|Zym_Search_Lucene_IQuery $query
* @param int $resultSetLimit
* @return array
*/
public function search($query, $resultSetLimit = null)
{
if (!$resultSetLimit) {
$resultSetLimit = self::$_defaultResultSetLimit;
}
Zend_Search_Lucene::setResultSetLimit((int) $resultSetLimit);
return $this->_searchIndex->find((string) $query);
}
示例13: getPageSimilarPageLinks
/**
* getPageSimilarPageLinks
* @return string $strReturn
* @author Cornelius Hansjakob <cha@massiveart.com>
* @version 1.0
*/
public function getPageSimilarPageLinks($intNumber = 5, $strContainerClass = 'links', $strItemClass = 'item')
{
$strReturn = '';
$strQuery = '';
$objPageTags = $this->objPage->getTagsValues('page_tags');
if (count($objPageTags) > 0) {
foreach ($objPageTags as $objTag) {
$strQuery .= 'page_tags:"' . $objTag->title . '" OR ';
}
}
$objPageCategories = $this->objPage->getCategoriesValues('category');
if (count($objPageCategories) > 0) {
foreach ($objPageCategories as $objCategory) {
$strQuery .= 'category:"' . $objCategory->title . '" OR ';
}
}
$strQuery = rtrim($strQuery, ' OR ');
if ($strQuery != '' && count(scandir(GLOBAL_ROOT_PATH . $this->core->sysConfig->path->search_index->page)) > 2) {
Zend_Search_Lucene::setResultSetLimit($intNumber);
$objIndex = Zend_Search_Lucene::open(GLOBAL_ROOT_PATH . $this->core->sysConfig->path->search_index->page);
$objHits = $objIndex->find($strQuery);
if (count($objHits) > 0) {
$strReturn .= '
<div class="' . $strContainerClass . '">
<h3>' . $this->objTranslate->_('Similar_pages') . '</h3>';
$counter = 1;
foreach ($objHits as $objHit) {
if ($objHit->key != $this->objPage->getPageId()) {
$objDoc = $objHit->getDocument();
$arrDocFields = $objDoc->getFieldNames();
if (array_search('url', $arrDocFields) && array_search('title', $arrDocFields) && array_search('date', $arrDocFields)) {
$strReturn .= '
<div class="item">
<a href="' . $objHit->url . '">' . htmlentities($objHit->title, ENT_COMPAT, $this->core->sysConfig->encoding->default) . '</a><br/>
<span>' . $this->objTranslate->_('Created_at') . '</span> <span class="black">' . $objHit->date . '</span>
</div>';
}
}
}
$strReturn .= '
<div class="clear"></div>
</div>';
}
}
return $strReturn;
}
示例14: performSearch
/**
* Perform a search query on the index
*/
public function performSearch()
{
try {
$index = Zend_Search_Lucene::open(self::get_index_location());
Zend_Search_Lucene::setResultSetLimit(200);
$this->results = $index->find($this->getQuery());
$this->totalResults = $index->numDocs();
} catch (Zend_Search_Lucene_Exception $e) {
user_error($e . '. Ensure you have run the rebuld task (/dev/tasks/RebuildLuceneDocsIndex)', E_USER_ERROR);
}
}
示例15: find
/**
*
* @since 5-24-11
*/
protected function find(Zend_Search_Lucene_Proxy $lucene, array $where_criteria)
{
$ret_list = array();
Zend_Search_Lucene::setResultSetLimit($where_criteria['limit'][0]);
if (empty($where_criteria['sort'])) {
$ret_list = $lucene->find($where_criteria['query']);
} else {
// http://framework.zend.com/manual/en/zend.search.lucene.searching.html#zend.search.lucene.searching.sorting
$args = $where_criteria['sort'];
array_unshift($args, $where_criteria['query']);
$ret_list = call_user_func_array(array($lucene, 'find'), $args);
}
//if/else
return $lucene->find($where_criteria['query']);
}