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


PHP Zend_Search_Lucene_Field::text方法代码示例

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


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

示例1: add

 public function add($needFields = array(), $data = array(), $charset = 'UTF-8')
 {
     $index = new Zend_Search_Lucene(ZY_ROOT . '/index', true);
     $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

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

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

示例4: __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

示例5: setUpBeforeClass

 /**
  * This method is called before the first test of this test class is run.
  *
  * Build a temporary index with a couple of documents
  */
 public static function setUpBeforeClass()
 {
     // ensure no index exist
     system(sprintf("rm -rf %s", self::indexDir()));
     // create the index
     $index = Zend_Search_Lucene::create(self::indexDir());
     // add some documents
     for ($i = 0; $i < 3; $i++) {
         $document = new Zend_Search_Lucene_Document();
         $document->addField(Zend_Search_Lucene_Field::text('title', "foo bar baz {$i}"));
         $document->addField(Zend_Search_Lucene_Field::text('content', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc pharetra laoreet sodales. Aenean consequat ornare aliquam. Etiam vestibulum ultrices elit nec vestibulum'));
         $index->addDocument($document);
     }
     $index->commit();
 }
开发者ID:JellyBellyDev,项目名称:zle,代码行数:20,代码来源:LuceneTest.php

示例6: searchImportFragment

function searchImportFragment($fragment, $index)
{
    if ($fragment->getType() != "text") {
        return;
    }
    $doc = new Zend_Search_Lucene_Document();
    $doc->addField(Zend_Search_Lucene_Field::text('uri', $fragment->getUri(), INDEX_CHARSET));
    $doc->addField(Zend_Search_Lucene_Field::text('user', $fragment->getCreatorId(), INDEX_CHARSET));
    $doc->addField(Zend_Search_Lucene_Field::text('created', $fragment->getCreateDate(), INDEX_CHARSET));
    $doc->addField(Zend_Search_Lucene_Field::text('modified', $fragment->getModifyDate(), INDEX_CHARSET));
    $doc->addField(Zend_Search_Lucene_Field::text('title', $fragment->getTitle(), INDEX_CHARSET));
    $doc->addField(Zend_Search_Lucene_Field::text('content', $fragment->getSaveContent(), INDEX_CHARSET));
    $doc->addField(Zend_Search_Lucene_Field::text('searchtext', $fragment->getTitle() . " " . $fragment->getContent(), INDEX_CHARSET));
    $ret = $index->addDocument($doc);
}
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:15,代码来源:search.php

示例7: index

 function index($title, $content, $url, $keywords, $user_id)
 {
     $this->initLuceneEngine();
     $id = $this->getId($url);
     $indexer = $this->zend->get_Zend_Search_Lucene();
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $id));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('userid', $user_id));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('url', $url));
     $doc->addField(Zend_Search_Lucene_Field::UnStored("content", $content, 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::text("title", $title, 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::text("keywords", $keywords, 'utf-8'));
     $indexer->addDocument($doc);
     $indexer->commit();
     //$indexer->optimize();
     return TRUE;
 }
开发者ID:cyberformed,项目名称:i2tree,代码行数:17,代码来源:search_engine_model.php

示例8: _build

 /**
  * Add node to index
  *
  * @param Zoo_Content_Interface $item
  */
 protected function _build(Zoo_Content_Interface $item)
 {
     // Delete existing document, if exists
     $hits = $this->index->find('nid:' . $item->id);
     foreach ($hits as $hit) {
         $this->index->delete($hit->id);
     }
     // (Re-)Index document
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::text('nid', $item->id));
     $doc->addField(Zend_Search_Lucene_Field::unIndexed('link', $item->url()));
     $doc->addField(Zend_Search_Lucene_Field::unStored('title', $item->title));
     $doc->addField(Zend_Search_Lucene_Field::unStored('type', $item->type));
     $doc->addField(Zend_Search_Lucene_Field::unStored('published', $item->published));
     $doc->addField(Zend_Search_Lucene_Field::unStored('uid', $item->uid));
     list($content) = Zoo::getService('content')->getRenderedContent($item->id, 'Display');
     $doc->addField(Zend_Search_Lucene_Field::unStored('contents', strip_tags($content)));
     return $doc;
 }
开发者ID:BGCX261,项目名称:zoocms-svn-to-git,代码行数:24,代码来源:Lucene.php

示例9: updateLuceneIndex

 public function updateLuceneIndex()
 {
     $index = trackTable::getLuceneIndex();
     // remove existing entries
     foreach ($index->find('pk:' . $this->getId()) as $hit) {
         $index->delete($hit->id);
     }
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $this->getId()));
     $doc->addField(Zend_Search_Lucene_Field::text('track_name', $this->getName(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::UnIndexed('track_url', $this->getUrl(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('play_it_user_id', $this->getSfGuardUser()->getId()));
     $doc->addField(Zend_Search_Lucene_Field::text('track_name', $this->getName(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::text('track_type', $this->getPlayList()->getObjectType(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::text('playlist_name', $this->getPlayList()->getTitle(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('play_owner_id', $this->getPlayList()->getPlayOwner()->getId()));
     $doc->addField(Zend_Search_Lucene_Field::text('play_owner_name', $this->getPlayList()->getPlayOwner()->getName(), 'utf-8'));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('play_owner_name_fr', $this->getPlayList()->getPlayOwner()->getNameFr(), 'utf-8'));
     $index->addDocument($doc);
     $index->commit();
 }
开发者ID:hielh,项目名称:abjihproject,代码行数:21,代码来源:track.class.php

示例10: index

 /**
  * php index.php db index
  *
  */
 public function index()
 {
     $query = "SELECT * FROM Products AS p JOIN Categories AS c ON p.CategoryID = c.CategoryId JOIN Suppliers AS s ON p.SupplierID = s.SupplierID";
     $stmt = $this->db->prepare($query);
     $stmt->execute();
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $indexDir = APP_PATH . '/' . self::INDEX_DIR;
     is_dir($indexDir) || mkdir($indexDir, 0777, true);
     $index = self::create($indexDir);
     foreach ($rows as $row) {
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::keyword('ProductName', $row['ProductName']));
         $doc->addField(Zend_Search_Lucene_Field::text('Quantity', $row['QuantityPerUnit']));
         $doc->addField(Zend_Search_Lucene_Field::keyword('Category', $row['CategoryName']));
         $doc->addField(Zend_Search_Lucene_Field::unIndexed('Description', $row['Description']));
         $doc->addField(Zend_Search_Lucene_Field::unStored('City', $row['City']));
         $doc->addField(Zend_Search_Lucene_Field::keyword('CompanyName', $row['CompanyName']));
         $doc->addField(Zend_Search_Lucene_Field::binary('Picture', $row['Picture']));
         $index->addDocument($doc);
     }
 }
开发者ID:uniqid,项目名称:lucene,代码行数:25,代码来源:IndexDb.php

示例11: insert

 function insert($dataObj, $user_id = 0, $object_type = JS_TEXT_DATA, $indexedContent = '', $isIndexed = TRUE, $keyHints = '')
 {
     $this->initLuceneEngine();
     $id = $this->getId($keyHints);
     $dataObjStr = '';
     if (!is_string($dataObj)) {
         $dataObjStr = json_encode($dataObj);
     }
     $data = PREFIX_JS_DATA . ' ' . $dataObjStr . ' ' . SUFFIX_JS_DATA;
     if (write_file('./js-data/' . $id . '.js', $data)) {
         $indexer = $this->zend->get_Zend_Search_Lucene();
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $id));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('userid', $user_id));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('object_type', $object_type));
         if ($isIndexed) {
             if ($object_type === JS_TEXT_DATA) {
                 $doc->addField(Zend_Search_Lucene_Field::UnStored("content", $indexedContent, 'utf-8'));
                 $doc->addField(Zend_Search_Lucene_Field::text("title", $dataObj['title'], 'utf-8'));
             } else {
                 if ($object_type === JS_STRUCTURED_DATA && is_string($dataObj)) {
                     $dataObj = json_decode($dataObj);
                     //unset Reserved Fields
                     unset($dataObj['id']);
                     unset($dataObj['userid']);
                     unset($dataObj['object_type']);
                     foreach ($dataObj as $key => $value) {
                         $doc->addField(Zend_Search_Lucene_Field::UnStored($key, $value, 'utf-8'));
                     }
                 }
             }
         }
         $indexer->addDocument($doc);
         $indexer->commit();
         //$indexer->optimize();
         return TRUE;
     }
     return FALSE;
 }
开发者ID:cyberformed,项目名称:i2tree,代码行数:39,代码来源:js_data_model.php

示例12: buildforum

 public function buildforum()
 {
     ini_set('memory_limit', '1000M');
     set_time_limit(0);
     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('forum_questions', array('tags', 'question', 'id'));
     $result = $this->_db->fetchAssoc($sql);
     /**
      * Create a document for each user and add it to the index
      */
     /*foreach ($users as $user) {
     		 $doc = new Zend_Search_Lucene_Document();
     	
     		/**
     		* Fill document with data
     		*/
     /*  $doc->addField(Zend_Search_Lucene_Field::unIndexed('title', $user->id));
     		 $doc->addField(Zend_Search_Lucene_Field::text('contents', $user->name));
     		//$doc->addField(Zend_Search_Lucene_Field::unIndexed('birthday', $user['dob'], 'UTF-8'));
     	
     		/**
     		* Add document
     		*/
     /*$index->addDocument($doc);
     		 }
     	
     		$index->optimize();
     		$index->commit();*/
     foreach ($result as $values) {
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::keyword('questionid', $values['id']));
         $doc->addField(Zend_Search_Lucene_Field::unStored('questions', $values['question']));
         $tag = explode(',', $values['tags']);
         $tags = implode(' ', $tag);
         $doc->addField(Zend_Search_Lucene_Field::text('tags', $tags));
         $index->addDocument($doc);
     }
     $index->commit();
 }
开发者ID:abdulnizam,项目名称:zend-freniz,代码行数:46,代码来源:forum.php

示例13: addToIndex

 protected function addToIndex($data)
 {
     if (trim($this->z_indexate) == '') {
         return;
     }
     if (!isset($data['id'])) {
         return;
     }
     $fields = explode(';', trim($this->z_indexate));
     $searchIndex = Z_Search::getInstance();
     //создаем документ
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::keyword('_id', $data['id']));
     $doc->addField(Zend_Search_Lucene_Field::unIndexed('_type', $this->z_model->info('name')));
     foreach ($fields as $field) {
         if (isset($data[$field])) {
             $doc->addField(Zend_Search_Lucene_Field::text($field, $data[$field]));
         }
     }
     //удаляем старый документ
     $hits = $searchIndex->find('_id:' . $data['id']);
     foreach ($hits as $hit) {
         $searchIndex->delete($hit->id);
     }
     //добавляем документ
     $searchIndex->addDocument($doc);
 }
开发者ID:Konstnantin,项目名称:zf-app,代码行数:27,代码来源:Abstract.php

示例14: insertPageDocument

 private function insertPageDocument($user, $doc)
 {
     $doc->addField(Zend_Search_Lucene_Field::keyword('userid', $user['userid']));
     $doc->addField(Zend_Search_Lucene_Field::keyword('type', $user['type']));
     $doc->addField(Zend_Search_Lucene_Field::text('username', $user['username']));
     $doc->addField(Zend_Search_Lucene_Field::unIndexed('user_url', $user['user_url']));
     $doc->addField(Zend_Search_Lucene_Field::unIndexed('propic', $user['pagepic_url']));
     $doc->addField(Zend_Search_Lucene_Field::unIndexed('vote', $user['page_vote']));
     $doc->addField(Zend_Search_Lucene_Field::keyword('category', $user['category']));
     $doc->addField(Zend_Search_Lucene_Field::keyword('subcategory', $user['subcategory']));
     $doc->addField(Zend_Search_Lucene_Field::keyword('bids', $user['bids']));
     return $doc;
 }
开发者ID:abdulnizam,项目名称:zend-freniz,代码行数:13,代码来源:Users.php

示例15: run_index_documents

function run_index_documents($task, $args)
{
    try {
        define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
        define('SF_APP', 'backend');
        define('SF_ENVIRONMENT', 'prod');
        define('SF_DEBUG', false);
        require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
        ini_set("memory_limit", "2048M");
        ini_set("display_errors", 1);
        $databaseManager = new sfDatabaseManager();
        $databaseManager->initialize();
        $search_config_file = SF_ROOT_DIR . '/config/search.xml';
        $documents = simplexml_load_file($search_config_file);
        $all = 0;
        $search_index_path = SF_ROOT_DIR . '/cache/search/';
        if (is_dir($search_index_path)) {
            $index_files = glob($search_index_path . '/*');
            foreach ($index_files as $index_file) {
                if (is_file($index_file)) {
                    unlink($index_file);
                }
            }
        }
        $search_index = Zend_Search_Lucene::create($search_index_path);
        $search_index->setMaxBufferedDocs(20000);
        Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
        $ndoc = 0;
        foreach ($documents as $document) {
            $document_name = $document->attributes();
            if (array_key_exists(0, $args) && $document_name != $args[0]) {
                continue;
            }
            echo "Indexing " . $document_name . "\n";
            $classPeer = $document_name . 'Peer';
            $c = new Criteria();
            $document_instances = call_user_func(array($classPeer, 'doSelect'), $c);
            foreach ($document_instances as $document_instance) {
                $common_field_val = "";
                $id = $document_instance->getId();
                $search_doc = new Zend_Search_Lucene_Document();
                $date = $document_instance->getCreatedAt();
                $search_doc->addField(Zend_Search_Lucene_Field::UnIndexed('did', $id, 'utf-8'));
                $search_doc->addField(Zend_Search_Lucene_Field::UnIndexed('ddate', $date, 'utf-8'));
                $search_doc->addField(Zend_Search_Lucene_Field::UnIndexed('dtype', $document_name, 'utf-8'));
                $search_doc->addField(Zend_Search_Lucene_Field::UnIndexed('dstatus', $document_instance->getPublicationStatus(), 'utf-8'));
                foreach ($document as $field_name) {
                    $attr = get_object_vars($field_name);
                    $attributes = $attr['@attributes'];
                    $getFunction = 'get' . $attributes['name'];
                    $fieldContent = "";
                    $fieldContent = $document_instance->{$getFunction}();
                    if ($attributes['name'] == "Label" and substr($fieldContent, 0, 8) == "no label") {
                        $fieldContent = "";
                    }
                    if ($attributes['name'] == "ViennaClasses" || $attributes['name'] == "NiceClasses") {
                        $parts = explode(",", $fieldContent);
                        $nbr = count($parts);
                        //echo "============>".$nbr."\n";
                        $search_doc->addField(Zend_Search_Lucene_Field::UnIndexed($attributes['name'] . "_cnt", $nbr, 'utf-8'));
                        //$e = 1;
                        for ($e = 0; $e < 15; $e++) {
                            if (empty($parts[$e])) {
                                $parts[$e] = "---";
                            }
                            $search_doc->addField(Zend_Search_Lucene_Field::keyword($attributes['name'] . $e, trim($parts[$e]), 'utf-8'));
                            $e++;
                        }
                    } elseif ($attributes['name'] == "ApplicationNumber" || $attributes['name'] == "RegisterNumber") {
                        $search_doc->addField(Zend_Search_Lucene_Field::keyword($attributes['name'], $fieldContent, 'utf-8'));
                    } else {
                        $search_doc->addField(Zend_Search_Lucene_Field::text($attributes['name'], UtilsHelper::cyrillicConvert($fieldContent), 'utf-8'));
                    }
                }
                $search_index->addDocument($search_doc);
                $ndoc++;
                echo $ndoc . "\t\t\r";
            }
        }
        echo echo_cms_line(" " . $ndoc . " documents indexed\n");
        $search_index->commit();
        $search_index->optimize();
    } catch (Exception $e) {
        echo_cms_error("ERROR ADD_DOCUMENT : " . $e->getMessage());
    }
    echo echo_cms_sep();
    exit;
}
开发者ID:kotow,项目名称:work,代码行数:88,代码来源:sfPakeIndexDocuments.php


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