当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Search_Lucene::setDefaultSearchField方法代码示例

本文整理汇总了PHP中Zend_Search_Lucene::setDefaultSearchField方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene::setDefaultSearchField方法的具体用法?PHP Zend_Search_Lucene::setDefaultSearchField怎么用?PHP Zend_Search_Lucene::setDefaultSearchField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Search_Lucene的用法示例。


在下文中一共展示了Zend_Search_Lucene::setDefaultSearchField方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: indexationSearch

 public static function indexationSearch($searchParams)
 {
     Zend_Search_Lucene::setDefaultSearchField('contents');
     $directory = Zend_Registry::get('lucene_index');
     $index = new Zend_Search_Lucene($directory);
     $words = strtolower(Cible_FunctionsGeneral::removeAccents(Cible_FunctionsGeneral::html2text(utf8_decode($searchParams['words']))));
     $wordsArray = explode(' ', $words);
     if (count($wordsArray) > 1) {
         $query = new Zend_Search_Lucene_Search_Query_Phrase($wordsArray);
     } else {
         if (strlen($words) >= 3) {
             $pattern = new Zend_Search_Lucene_Index_Term("{$words}*");
             $query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
         } else {
             $term = new Zend_Search_Lucene_Index_Term($words);
             $query = new Zend_Search_Lucene_Search_Query_Term($term);
         }
     }
     $hits = $index->find($query);
     //echo($query);
     $i = 0;
     $result = array();
     foreach ($hits as $hit) {
         $result[$i]['moduleID'] = $hit->moduleID;
         $result[$i]['pageID'] = $hit->pageID;
         $result[$i]['contentID'] = $hit->contentID;
         $result[$i]['languageID'] = $hit->languageID;
         $result[$i]['title'] = $hit->title;
         $result[$i]['text'] = $hit->text;
         $result[$i]['link'] = $hit->link;
         $i++;
     }
     return $result;
 }
开发者ID:anunay,项目名称:stentors,代码行数:34,代码来源:FunctionsIndexation.php

示例3: testDefaultSearchField

 public function testDefaultSearchField()
 {
     $currentDefaultSearchField = Zend_Search_Lucene::getDefaultSearchField();
     $this->assertEquals($currentDefaultSearchField, null);
     Zend_Search_Lucene::setDefaultSearchField('anotherField');
     $this->assertEquals(Zend_Search_Lucene::getDefaultSearchField(), 'anotherField');
     Zend_Search_Lucene::setDefaultSearchField($currentDefaultSearchField);
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:8,代码来源:LuceneTest.php

示例4: searchTag

 public function searchTag($tag, $value)
 {
     if (!$this->_enabled) {
         return array();
     }
     Zend_Search_Lucene::setDefaultSearchField($tag);
     $query = Zend_Search_Lucene_Search_QueryParser::parse($value);
     return $this->_index->find($query);
 }
开发者ID:ntulip,项目名称:joobsbox-php,代码行数:9,代码来源:Search.php

示例5: setDefaultSearchField

 /**
  * Set default search field.
  *
  * Null means, that search is performed through all fields by default
  *
  * Default value is null
  *
  * @param string $fieldName
  */
 public static function setDefaultSearchField($fieldName)
 {
     Zend_Search_Lucene::setDefaultSearchField($fieldName);
 }
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:13,代码来源:Proxy.php

示例6: testQueryHit

 public function testQueryHit()
 {
     // Restore default search field if it wasn't done by previous test because of failure
     Zend_Search_Lucene::setDefaultSearchField(null);
     $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_index23Sample/_files');
     $hits = $index->find('submitting AND wishlists');
     $hit = $hits[0];
     $this->assertTrue($hit instanceof Zend_Search_Lucene_Search_QueryHit);
     $this->assertTrue($hit->getIndex() instanceof Zend_Search_Lucene_Interface);
     $doc = $hit->getDocument();
     $this->assertTrue($doc instanceof Zend_Search_Lucene_Document);
     $this->assertEquals($doc->path, 'IndexSource/contributing.html');
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:13,代码来源:Search23Test.php

示例7: testDefaultSearchField

    public function testDefaultSearchField()
    {
        $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_files/_indexSample');

        $storedDefaultSearchField = Zend_Search_Lucene::getDefaultSearchField();

        Zend_Search_Lucene::setDefaultSearchField('path');
        $hits = $index->find('contributing');

        $this->assertEquals(count($hits), 5);
        $expectedResultset = array(array(8, 0.847922, 'IndexSource/contributing.html'),
                                   array(0, 0.678337, 'IndexSource/contributing.documentation.html'),
                                   array(1, 0.678337, 'IndexSource/contributing.wishlist.html'),
                                   array(2, 0.678337, 'IndexSource/contributing.patches.html'),
                                   array(7, 0.678337, 'IndexSource/contributing.bugs.html'));

        foreach ($hits as $resId => $hit) {
            $this->assertEquals($hit->id, $expectedResultset[$resId][0]);
            $this->assertTrue( abs($hit->score - $expectedResultset[$resId][1]) < 0.000001 );
            $this->assertEquals($hit->path, $expectedResultset[$resId][2]);
        }

        Zend_Search_Lucene::setDefaultSearchField($storedDefaultSearchField);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:24,代码来源:SearchTest.php

示例8: findAction

 public function findAction()
 {
     $queryFromRequest = $this->cleanRequestString($_REQUEST["query"]);
     $categoryFromRequest = $this->cleanRequestString($_REQUEST["cat"]);
     $searcher = new SearchPhp_Frontend_Searcher();
     $this->view->groupByCategory = $this->_getParam("groupByCategory");
     $this->view->omitSearchForm = $this->_getParam("omitSearchForm");
     $this->view->categoryOrder = $this->_getParam("categoryOrder");
     $this->view->omitJsIncludes = $this->_getParam("omitJsIncludes");
     $perPage = $this->_getParam("perPage");
     if (empty($perPage)) {
         $perPage = 10;
     }
     $page = $this->_getParam("page");
     if (empty($page)) {
         $page = 1;
     }
     $queryStr = strtolower($queryFromRequest);
     $this->view->category = $categoryFromRequest;
     if (!empty($this->view->category)) {
         $category = $this->view->category;
     } else {
         $category = null;
     }
     $pluginConf = SearchPhp_Plugin::getSearchConfigArray();
     if (!empty($pluginConf["search"]["frontend"]["categories"])) {
         $this->view->availableCategories = explode(",", $pluginConf["search"]["frontend"]["categories"]);
     }
     $doFuzzy = $this->_getParam("fuzzy");
     try {
         $query = new Zend_Search_Lucene_Search_Query_Boolean();
         $field = $this->_getParam("field");
         if (!empty($field)) {
             Zend_Search_Lucene::setDefaultSearchField($field);
         }
         $searchResults = array();
         if (!empty($queryStr)) {
             if ($doFuzzy) {
                 $queryStr = str_replace(" ", "~ ", $queryStr);
                 $queryStr .= "~";
                 Zend_Search_Lucene_Search_Query_Fuzzy::setDefaultPrefixLength(3);
             }
             $userQuery = Zend_Search_Lucene_Search_QueryParser::parse($queryStr, 'utf-8');
             $query->addSubquery($userQuery, true);
             if (!empty($this->searchLanguage)) {
                 if (is_object($this->searchLanguage)) {
                     $lang = $this->searchLanguage->toString();
                 } else {
                     $lang = $this->searchLanguage;
                 }
                 $lang = str_replace(array("_", "-"), "", $lang);
                 $languageTerm = new Zend_Search_Lucene_Index_Term($lang, 'lang');
                 $languageQuery = new Zend_Search_Lucene_Search_Query_Term($languageTerm);
                 $query->addSubquery($languageQuery, true);
             }
             if (!empty($category)) {
                 $categoryTerm = new Zend_Search_Lucene_Index_Term($category, 'cat');
                 $categoryQuery = new Zend_Search_Lucene_Search_Query_Term($categoryTerm);
                 $query->addSubquery($categoryQuery, true);
             }
             $hits = $this->frontendIndex->find($query);
             $validHits = array();
             if ($this->ownHostOnly and $hits != null) {
                 //get rid of hits from other hosts
                 $currenthost = $_SERVER['HTTP_HOST'];
                 for ($i = 0; $i < count($hits); $i++) {
                     $url = $hits[$i]->getDocument()->getField("url");
                     if (strpos($url->value, "http://" . $currenthost) !== FALSE || strpos($url->value, "https://" . $currenthost) !== FALSE) {
                         $validHits[] = $hits[$i];
                     }
                 }
             } else {
                 $validHits = $hits;
             }
             $start = $perPage * ($page - 1);
             $end = $start + ($perPage - 1);
             if ($end > count($validHits) - 1) {
                 $end = count($validHits) - 1;
             }
             for ($i = $start; $i <= $end; $i++) {
                 $hit = $validHits[$i];
                 $url = $hit->getDocument()->getField("url");
                 $title = $hit->getDocument()->getField("title");
                 $searchResult['boost'] = $hit->getDocument()->boost;
                 $searchResult['title'] = $title->value;
                 $searchResult['url'] = $url->value;
                 $searchResult['sumary'] = $searcher->getSumaryForUrl($url->value, $queryStr);
                 try {
                     if ($hit->getDocument()->getField("h1")) {
                         $searchResult['h1'] = $hit->getDocument()->getField("h1")->value;
                     }
                 } catch (Zend_Search_Lucene_Exception $e) {
                 }
                 foreach ($this->categories as $category) {
                     try {
                         $searchResult['categories'][] = $hit->getDocument()->getField("cat")->value;
                     } catch (Zend_Search_Lucene_Exception $e) {
                     }
                 }
                 $searchResults[] = $searchResult;
//.........这里部分代码省略.........
开发者ID:weblizards-gmbh,项目名称:search-php,代码行数:101,代码来源:FrontendController.php

示例9: date_default_timezone_set

}
date_default_timezone_set(require Environment::expand('%timezoneFile%'));
// debugging
Debug::enable(NULL, BASE_DIR . '/error.log', Environment::expand('%adminEmail%'));
// paths
Environment::setVariable('themeDir', Environment::expand('%baseDir%/themes'));
Environment::setVariable('templatesDir', Environment::expand('%themeDir%/%theme%'));
Environment::setVariable('tempDir', Environment::expand('%baseDir%/tmp'));
Environment::setVariable('themeBaseUri', Environment::expand('%baseUri%/themes/%theme%'));
Environment::setVariable('mediaDir', Environment::expand('%baseDir%/media'));
Environment::setVariable('mediaBaseUri', Environment::expand('%baseUri%/media'));
set_include_path(LIB_DIR . PATH_SEPARATOR . get_include_path());
Html::$xhtml = FALSE;
SafeStream::register();
setlocale(LC_ALL, require Environment::expand('%localeFile%'));
Zend_Search_Lucene::setDefaultSearchField('description');
// configure locale
require_once LIB_DIR . '/tr.php';
$available = array();
foreach (glob(APP_DIR . '/locale/' . '*.php') as $_) {
    $available[substr(substr($_, strlen(APP_DIR . '/locale/')), 0, 2)] = $_;
}
tr::$locale = Environment::getHttpRequest()->detectLanguage(array_keys($available));
if (tr::$locale) {
    list(tr::$plurals[tr::$locale], tr::$table[tr::$locale]) = (require $available[tr::$locale]);
}
// connect to DB
dibi::connect(require Environment::expand('%dbFile%'));
// get app
$app = Environment::getApplication();
// routing
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:31,代码来源:bootstrap.php

示例10: findAction

 public function findAction()
 {
     $this->disableViewAutoRender();
     $searcher = new Searcher();
     try {
         $query = new \Zend_Search_Lucene_Search_Query_Boolean();
         $field = $this->getParam('field');
         if (!empty($field)) {
             \Zend_Search_Lucene::setDefaultSearchField($field);
         }
         $searchResults = array();
         $validHits = array();
         if (!empty($this->query)) {
             if ($this->fuzzySearch) {
                 $this->query = str_replace(' ', '~ ', $this->query);
                 $this->query .= '~';
                 \Zend_Search_Lucene_Search_Query_Fuzzy::setDefaultPrefixLength(3);
             }
             $userQuery = \Zend_Search_Lucene_Search_QueryParser::parse($this->query, 'utf-8');
             $query->addSubquery($userQuery, TRUE);
             $this->addLanguageQuery($query);
             $this->addCountryQuery($query);
             $this->addCategoryQuery($query);
             $this->addRestrictionQuery($query);
             $validHits = $this->getValidHits($this->frontendIndex->find($query));
             $start = $this->perPage * ($this->currentPage - 1);
             $end = $start + ($this->perPage - 1);
             if ($end > count($validHits) - 1) {
                 $end = count($validHits) - 1;
             }
             for ($i = $start; $i <= $end; $i++) {
                 $hit = $validHits[$i];
                 /** @var \Zend_Search_Lucene_Document $doc */
                 $doc = $hit->getDocument();
                 $url = $doc->getField('url');
                 $title = $doc->getField('title');
                 $content = $doc->getField('content');
                 $searchResult['boost'] = $doc->boost;
                 $searchResult['title'] = $title->value;
                 $searchResult['url'] = $url->value;
                 $searchResult['summary'] = $searcher->getSummaryForUrl($content->value, $this->untouchedQuery);
                 //H1, description and imageTags are not available in pdf files.
                 try {
                     if ($doc->getField('h1')) {
                         $searchResult['h1'] = $doc->getField('h1')->value;
                     }
                     if ($doc->getField('description')) {
                         $searchResult['description'] = $searcher->getSummaryForUrl($doc->getField('description')->value, $this->untouchedQuery);
                     }
                     if ($doc->getField('imageTags')) {
                         $searchResult['imageTags'] = $doc->getField('imageTags')->value;
                     }
                 } catch (\Zend_Search_Lucene_Exception $e) {
                 }
                 foreach ($this->categories as $category) {
                     try {
                         $searchResult['categories'][] = $hit->getDocument()->getField('cat')->value;
                     } catch (\Zend_Search_Lucene_Exception $e) {
                     }
                 }
                 $searchResults[] = $searchResult;
                 unset($searchResult);
             }
         }
         $suggestions = FALSE;
         if ($this->fuzzySearch) {
             $suggestions = $this->getFuzzySuggestions($searchResults);
         }
         $currentPageResultStart = $this->perPage * ($this->currentPage - 1);
         $currentPageResultEnd = $currentPageResultStart + $this->perPage;
         if ($currentPageResultEnd > count($validHits)) {
             $currentPageResultEnd = count($validHits);
         }
         $pages = 0;
         if (count($validHits) > 0) {
             $pages = ceil(count($validHits) / $this->perPage);
         }
         $this->view->assign(['searchCurrentPage' => $this->currentPage, 'searchAllPages' => $pages, 'searchCategory' => $this->category, 'searchAvailableCategories' => $this->categories, 'searchSuggestions' => $suggestions, 'searchLanguage' => $this->searchLanguage, 'searchCountry' => $this->searchCountry, 'searchPerPage' => $this->perPage, 'searchTotalHits' => count($validHits), 'searchQuery' => $this->untouchedQuery, 'searchHasResults' => count($searchResults) > 0, 'searchResults' => $searchResults, 'searchCurrentPageResultStart' => $currentPageResultStart + 1, 'searchCurrentPageResultEnd' => $currentPageResultEnd]);
     } catch (\Exception $e) {
         \Pimcore\Logger::debug('An Exception occurred during search: ' . $e->getMessage());
         $this->view->assign(['searchResults' => [], 'searchHasResults' => FALSE]);
     }
     if ($this->getParam('viewScript')) {
         $this->renderScript($this->_getParam('viewScript'));
     } else {
         $this->renderScript('/search/find.php');
     }
 }
开发者ID:dachcom-digital,项目名称:pimcore-lucene-search,代码行数:88,代码来源:FrontendController.php


注:本文中的Zend_Search_Lucene::setDefaultSearchField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。