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


PHP Zend_Search_Lucene_Search_Query_MultiTerm::addTerm方法代码示例

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


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

示例1: delete

 /**
  * Removes search entry of current entity from the index.
  * 
  * @return Mage_Lucene_Model_Index_Document_Abstract
  **/
 protected function delete()
 {
     $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
     $query->addTerm(new Zend_Search_Lucene_Index_Term($this->_id, 'entity_id'), true);
     $query->addTerm(new Zend_Search_Lucene_Index_Term($this->getDoctype(), 'doctype'), true);
     $query->addTerm(new Zend_Search_Lucene_Index_Term($this->getStore()->getId(), self::STORE_ATTRIBUTE_CODE), true);
     $this->deleteByQuery($query);
     return $this;
 }
开发者ID:rickboyau,项目名称:magento-lucene,代码行数:14,代码来源:Abstract.php

示例2: indexAction

 /**
  * The main workshop page.  It has the list of all the workshops that are 
  * available in the system.
  *
  */
 public function indexAction()
 {
     $this->view->acl = array('workshopList' => $this->_helper->hasAccess('workshop-list'));
     $get = Zend_Registry::get('getFilter');
     $form = new Zend_Form();
     $form->setAttrib('id', 'workshopForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form'));
     $searchField = $form->createElement('text', 'search', array('label' => 'workshop-index-index:searchWorkshops'));
     $searchField->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($get->search) ? $get->search : '');
     $category = new Category();
     $categoryList = $category->fetchAll(null, 'name');
     $categories = $form->createElement('select', 'categoryId');
     $categories->addMultiOption('', '-- Search By Category -- ');
     foreach ($categoryList as $c) {
         $categories->addMultiOption($c['categoryId'], $c['name']);
     }
     $categories->setValue(isset($get->categoryId) ? $get->categoryId : '');
     $submit = $form->createElement('submit', 'submitButton', array('label' => 'workshop-index-index:search'));
     $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit'))));
     $form->addElements(array($searchField, $categories));
     $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit));
     $this->view->form = $form;
     $searchTerm = new Search_Term();
     $workshops = array();
     if ($get->search != '' || $get->categoryId != 0) {
         $workshop = new Workshop();
         $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
         if ($get->search != '') {
             $query->addTerm(new Zend_Search_Lucene_Index_Term($get->search), true);
         }
         if ($get->categoryId != 0) {
             $query->addTerm(new Zend_Search_Lucene_Index_Term($get->categoryId, 'categoryId'), true);
         }
         $workshops = $workshop->search($query);
         $searchTerm->increment($get->search);
         $this->view->searchTerm = $get->search;
     }
     $this->view->workshops = $workshops;
     $this->view->topTerms = $searchTerm->getTopSearchTerms(10);
     $this->view->layout()->setLayout('search');
     $this->view->layout()->rightContent = $this->view->render('index/top-terms.phtml');
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css');
     $this->_helper->pageTitle("workshop-index-index:title");
 }
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:49,代码来源:IndexController.php

示例3: rewrite

 /**
  * Re-write query into primitive queries in the context of specified index
  *
  * @param Zend_Search_Lucene_Interface $index
  * @return Zend_Search_Lucene_Search_Query
  */
 public function rewrite(Zend_Search_Lucene_Interface $index)
 {
     if ($this->_term->field != null) {
         return $this;
     } else {
         $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
         $query->setBoost($this->getBoost());
         foreach ($index->getFieldNames(true) as $fieldName) {
             $term = new Zend_Search_Lucene_Index_Term($this->_term->text, $fieldName);
             $query->addTerm($term);
         }
         return $query->rewrite($index);
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:Term.php

示例4: rewrite

 /**
  * Re-write query into primitive queries in the context of specified index
  *
  * @param Zend_Search_Lucene_Interface $index
  * @return Zend_Search_Lucene_Search_Query
  */
 public function rewrite(Zend_Search_Lucene_Interface $index)
 {
     if ($this->_term->field != null) {
         return $this;
     } else {
         require_once PHP_LIBRARY_PATH . 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
         $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
         $query->setBoost($this->getBoost());
         require_once PHP_LIBRARY_PATH . 'Zend/Search/Lucene/Index/Term.php';
         foreach ($index->getFieldNames(true) as $fieldName) {
             $term = new Zend_Search_Lucene_Index_Term($this->_term->text, $fieldName);
             $query->addTerm($term);
         }
         return $query->rewrite($index);
     }
 }
开发者ID:netixx,项目名称:Stock,代码行数:22,代码来源:Term.php

示例5: rewrite

 /**
  * Re-write query into primitive queries in the context of specified index
  *
  * @param Zend_Search_Lucene_Interface $index
  * @return Zend_Search_Lucene_Search_Query
  */
 public function rewrite(Zend_Search_Lucene_Interface $index)
 {
     if ($this->_term->field != null) {
         return $this;
     } else {
         require_once sfConfig::get('sf_lib_dir') . '/modules/search/lib/Lucene/Search/Query/MultiTerm.php';
         $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
         $query->setBoost($this->getBoost());
         require_once sfConfig::get('sf_lib_dir') . '/modules/search/lib/Lucene/Index/Term.php';
         foreach ($index->getFieldNames(true) as $fieldName) {
             $term = new Zend_Search_Lucene_Index_Term($this->_term->text, $fieldName);
             $query->addTerm($term);
         }
         return $query->rewrite($index);
     }
 }
开发者ID:kotow,项目名称:work,代码行数:22,代码来源:Term.php

示例6: prepareLuceneQuery

 protected function prepareLuceneQuery($keyword)
 {
     $keyword = strtolower($keyword);
     $query = new Zend_Search_Lucene_Search_Query_Boolean();
     # multiterm query
     $subquery1 = new Zend_Search_Lucene_Search_Query_MultiTerm();
     foreach (explode(' ', $keyword) as $key) {
         if (!trim($key)) {
             continue;
         }
         $subquery1->addTerm(new Zend_Search_Lucene_Index_Term($key));
     }
     # wildcard query
     Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(1);
     $tokens = preg_split('/ /', $keyword, -1, PREG_SPLIT_NO_EMPTY);
     $lastWord = trim(array_pop($tokens)) . "*";
     $pattern = new Zend_Search_Lucene_Index_Term($lastWord);
     $subquery2 = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
     $query->addSubquery($subquery1);
     $query->addSubquery($subquery2);
     return $query;
 }
开发者ID:vcgato29,项目名称:poff,代码行数:22,代码来源:actions.class.php

示例7: getQuery

 /**
  * Transform entry to a subquery
  *
  * @param string $encoding
  * @return Zend_Search_Lucene_Search_Query
  * @throws Zend_Search_Lucene_Search_QueryParserException
  */
 public function getQuery($encoding)
 {
     if ($this->_fuzzyQuery) {
         throw new Zend_Search_Lucene_Search_QueryParserException('Fuzzy search is not supported yet.');
     }
     if (strpos($this->_term, '?') !== false || strpos($this->_term, '*') !== false) {
         throw new Zend_Search_Lucene_Search_QueryParserException('Wildcard queries are not supported yet.');
     }
     $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_term, $encoding);
     if (count($tokens) == 0) {
         return new Zend_Search_Lucene_Search_Query_Insignificant();
     }
     if (count($tokens) == 1) {
         $term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field);
         $query = new Zend_Search_Lucene_Search_Query_Term($term);
         $query->setBoost($this->_boost);
         return $query;
     }
     //It's not empty or one term query
     $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
     /**
      * @todo Process $token->getPositionIncrement() to support stemming, synonyms and other
      * analizer design features
      */
     foreach ($tokens as $token) {
         $term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $this->_field);
         $query->addTerm($term, true);
         // all subterms are required
     }
     $query->setBoost($this->_boost);
     return $query;
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:39,代码来源:Term.php

示例8: rewrite

 /**
  * Re-write query into primitive queries in the context of specified index
  *
  * @param Zend_Search_Lucene_Interface $index
  * @return Zend_Search_Lucene_Search_Query
  */
 public function rewrite(Zend_Search_Lucene_Interface $index)
 {
     $this->_matches = array();
     if ($this->_pattern->field === null) {
         // Search through all fields
         $fields = $index->getFieldNames(true);
     } else {
         $fields = array($this->_pattern->field);
     }
     $prefix = self::_getPrefix($this->_pattern->text);
     $prefixLength = strlen($prefix);
     $matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*'), preg_quote($this->_pattern->text, '/')) . '$/';
     /** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */
     if (@preg_match('/\\pL/u', 'a') == 1) {
         // PCRE unicode support is turned on
         // add Unicode modifier to the match expression
         $matchExpression .= 'u';
     }
     foreach ($fields as $field) {
         $index->resetTermsStream();
         if ($prefix != '') {
             $index->skipTo(new Zend_Search_Lucene_Index_Term($prefix, $field));
             while ($index->currentTerm() !== null && $index->currentTerm()->field == $field && substr($index->currentTerm()->text, 0, $prefixLength) == $prefix) {
                 if (preg_match($matchExpression, $index->currentTerm()->text) === 1) {
                     $this->_matches[] = $index->currentTerm();
                 }
                 $index->nextTerm();
             }
         } else {
             $index->skipTo(new Zend_Search_Lucene_Index_Term('', $field));
             while ($index->currentTerm() !== null && $index->currentTerm()->field == $field) {
                 if (preg_match($matchExpression, $index->currentTerm()->text) === 1) {
                     $this->_matches[] = $index->currentTerm();
                 }
                 $index->nextTerm();
             }
         }
         $index->closeTermsStream();
     }
     if (count($this->_matches) == 0) {
         return new Zend_Search_Lucene_Search_Query_Empty();
     } else {
         if (count($this->_matches) == 1) {
             return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches));
         } else {
             $rewrittenQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
             foreach ($this->_matches as $matchedTerm) {
                 $rewrittenQuery->addTerm($matchedTerm);
             }
             return $rewrittenQuery;
         }
     }
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:59,代码来源:Wildcard.php

示例9: get_similar_posts

 /**
  * Return a list of posts that are similar to the current post.
  * This is not a very good implementation, so do not expect 
  * amazing results - the term vector is not available for a doc
  * in ZSL, which limits how far you can go!
  *
  * @return array ids 
  */
 public function get_similar_posts($post, $max_recommended = 5)
 {
     Zend_Search_Lucene::setResultSetLimit($max_recommended + 1);
     $title = $post->title;
     $tags = $post->tags;
     $tagstring = '';
     foreach ($tags as $tag) {
         $tagstring .= $tag . ' ';
     }
     $analyser = Zend_Search_Lucene_Analysis_Analyzer::getDefault();
     $tokens = $analyser->tokenize(strtolower($tagstring) . ' ' . strtolower($title));
     $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
     foreach ($tokens as $token) {
         $query->addTerm(new Zend_Search_Lucene_Index_Term($token->getTermText()));
     }
     $hits = $this->_index->find($query);
     $ids = array();
     $counter = 0;
     foreach ($hits as $hit) {
         if ($hit->postid != $post->id) {
             $ids[] = $hit->postid;
             $counter++;
         }
         if ($counter == $max_recommended) {
             break;
         }
     }
     return $ids;
 }
开发者ID:habari-extras,项目名称:multisearch,代码行数:37,代码来源:zendsearchlucene.php

示例10:

<?php

require_once '/var/www/library/Zend/Search/Lucene.php';
Zend_Search_Lucene::create('/tmp/index');
// Doesn't work when including a number:
$searchTerm = '12stones';
$index = Zend_Search_Lucene::open('/tmp/index');
$document = new Zend_Search_Lucene_Document();
$document->addField(Zend_Search_Lucene_Field::Text('test', $searchTerm));
$index->addDocument($document);
$index->commit();
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$query->addTerm(new Zend_Search_Lucene_Index_Term($searchTerm, 'test'), true);
$hits = $index->find($query);
echo 'Hits:';
// For my use case, this should return one hit, however, it currently returns none:
foreach ($hits as $hit) {
    var_dump($hit->test);
}
开发者ID:Tony133,项目名称:zf-web,代码行数:19,代码来源:index.php

示例11: deleteByIdLanguage

 /**
  * Delete an existing document from the index
  *
  * @param integer $id object identifier
  * @param string $language ISO-639-1 code
  * @return void
  */
 public static function deleteByIdLanguage($id, $language)
 {
     // have to use another search object to perform the querying
     $querier = new QubitSearch();
     $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
     $query->addTerm(new Zend_Search_Lucene_Index_Term($id, 'id'), true);
     $query->addTerm(new Zend_Search_Lucene_Index_Term($language, 'culture'), true);
     foreach ($querier->getEngine()->getIndex()->find($query) as $hit) {
         self::getInstance()->getEngine()->getIndex()->delete($hit->id);
     }
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:18,代码来源:QubitSearch.class.php

示例12: rewrite

 /**
  * Re-write query into primitive queries in the context of specified index
  *
  * @param Zend_Search_Lucene_Interface $index
  * @return Zend_Search_Lucene_Search_Query
  */
 public function rewrite(Zend_Search_Lucene_Interface $index)
 {
     if ($this->_field === null) {
         require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
         $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
         $query->setBoost($this->getBoost());
         $hasInsignificantSubqueries = false;
         require_once 'Zend/Search/Lucene.php';
         if (Zend_Search_Lucene::getDefaultSearchField() === null) {
             $searchFields = $index->getFieldNames(true);
         } else {
             $searchFields = array(Zend_Search_Lucene::getDefaultSearchField());
         }
         require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Term.php';
         foreach ($searchFields as $fieldName) {
             $subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Term($this->_word, $this->_encoding, $fieldName);
             $rewrittenSubquery = $subquery->rewrite($index);
             foreach ($rewrittenSubquery->getQueryTerms() as $term) {
                 $query->addTerm($term);
             }
             if ($rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Insignificant) {
                 $hasInsignificantSubqueries = true;
             }
         }
         if (count($query->getTerms()) == 0) {
             $this->_matches = array();
             if ($hasInsignificantSubqueries) {
                 require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php';
                 return new Zend_Search_Lucene_Search_Query_Insignificant();
             } else {
                 require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
                 return new Zend_Search_Lucene_Search_Query_Empty();
             }
         }
         $this->_matches = $query->getQueryTerms();
         return $query;
     }
     // -------------------------------------
     // Recognize exact term matching (it corresponds to Keyword fields stored in the index)
     // encoding is not used since we expect binary matching
     require_once 'Zend/Search/Lucene/Index/Term.php';
     $term = new Zend_Search_Lucene_Index_Term($this->_word, $this->_field);
     if ($index->hasTerm($term)) {
         require_once 'Zend/Search/Lucene/Search/Query/Term.php';
         $query = new Zend_Search_Lucene_Search_Query_Term($term);
         $query->setBoost($this->getBoost());
         $this->_matches = $query->getQueryTerms();
         return $query;
     }
     // -------------------------------------
     // Recognize wildcard queries
     /** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */
     if (@preg_match('/\\pL/u', 'a') == 1) {
         $word = iconv($this->_encoding, 'UTF-8', $this->_word);
         $wildcardsPattern = '/[*?]/u';
         $subPatternsEncoding = 'UTF-8';
     } else {
         $word = $this->_word;
         $wildcardsPattern = '/[*?]/';
         $subPatternsEncoding = $this->_encoding;
     }
     $subPatterns = preg_split($wildcardsPattern, $word, -1, PREG_SPLIT_OFFSET_CAPTURE);
     if (count($subPatterns) > 1) {
         // Wildcard query is recognized
         $pattern = '';
         require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
         foreach ($subPatterns as $id => $subPattern) {
             // Append corresponding wildcard character to the pattern before each sub-pattern (except first)
             if ($id != 0) {
                 $pattern .= $word[$subPattern[1] - 1];
             }
             // Check if each subputtern is a single word in terms of current analyzer
             $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($subPattern[0], $subPatternsEncoding);
             if (count($tokens) > 1) {
                 require_once 'Zend/Search/Lucene/Search/QueryParserException.php';
                 throw new Zend_Search_Lucene_Search_QueryParserException('Wildcard search is supported only for non-multiple word terms');
             }
             foreach ($tokens as $token) {
                 $pattern .= $token->getTermText();
             }
         }
         require_once 'Zend/Search/Lucene/Index/Term.php';
         $term = new Zend_Search_Lucene_Index_Term($pattern, $this->_field);
         require_once 'Zend/Search/Lucene/Search/Query/Wildcard.php';
         $query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
         $query->setBoost($this->getBoost());
         // Get rewritten query. Important! It also fills terms matching container.
         $rewrittenQuery = $query->rewrite($index);
         $this->_matches = $query->getQueryTerms();
         return $rewrittenQuery;
     }
     // -------------------------------------
     // Recognize one-term multi-term and "insignificant" queries
     require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
//.........这里部分代码省略.........
开发者ID:be-dmitry,项目名称:zf1,代码行数:101,代码来源:Term.php

示例13: rewrite

 /**
  * Re-write query into primitive queries in the context of specified index
  *
  * @param Zend_Search_Lucene_Interface $index
  * @return Zend_Search_Lucene_Search_Query
  */
 public function rewrite(Zend_Search_Lucene_Interface $index)
 {
     $this->_matches = array();
     if ($this->_field === null) {
         // Search through all fields
         $fields = $index->getFieldNames(true);
     } else {
         $fields = array($this->_field);
     }
     // require_once 'Zend/Search/Lucene.php';
     $maxTerms = Zend_Search_Lucene::getTermsPerQueryLimit();
     foreach ($fields as $field) {
         $index->resetTermsStream();
         // require_once 'Zend/Search/Lucene/Index/Term.php';
         if ($this->_lowerTerm !== null) {
             $lowerTerm = new Zend_Search_Lucene_Index_Term($this->_lowerTerm->text, $field);
             $index->skipTo($lowerTerm);
             if (!$this->_inclusive && $index->currentTerm() == $lowerTerm) {
                 // Skip lower term
                 $index->nextTerm();
             }
         } else {
             $index->skipTo(new Zend_Search_Lucene_Index_Term('', $field));
         }
         if ($this->_upperTerm !== null) {
             // Walk up to the upper term
             $upperTerm = new Zend_Search_Lucene_Index_Term($this->_upperTerm->text, $field);
             while ($index->currentTerm() !== null && $index->currentTerm()->field == $field && strcmp($index->currentTerm()->text, $upperTerm->text) < 0) {
                 $this->_matches[] = $index->currentTerm();
                 if ($maxTerms != 0 && count($this->_matches) > $maxTerms) {
                     // require_once 'Zend/Search/Lucene/Exception.php';
                     throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
                 }
                 $index->nextTerm();
             }
             if ($this->_inclusive && $index->currentTerm() == $upperTerm) {
                 // Include upper term into result
                 $this->_matches[] = $upperTerm;
             }
         } else {
             // Walk up to the end of field data
             while ($index->currentTerm() !== null && $index->currentTerm()->field == $field) {
                 $this->_matches[] = $index->currentTerm();
                 if ($maxTerms != 0 && count($this->_matches) > $maxTerms) {
                     // require_once 'Zend/Search/Lucene/Exception.php';
                     throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.');
                 }
                 $index->nextTerm();
             }
         }
         $index->closeTermsStream();
     }
     if (count($this->_matches) == 0) {
         // require_once 'Zend/Search/Lucene/Search/Query/Empty.php';
         return new Zend_Search_Lucene_Search_Query_Empty();
     } else {
         if (count($this->_matches) == 1) {
             // require_once 'Zend/Search/Lucene/Search/Query/Term.php';
             return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches));
         } else {
             // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
             $rewrittenQuery = new Zend_Search_Lucene_Search_Query_MultiTerm();
             foreach ($this->_matches as $matchedTerm) {
                 $rewrittenQuery->addTerm($matchedTerm);
             }
             return $rewrittenQuery;
         }
     }
 }
开发者ID:alefernie,项目名称:intranet,代码行数:75,代码来源:Range.php

示例14: Foo

    $criteria->addField(new Foo());
    $t->fail('->addField() rejects invalid values');
} catch (Exception $e) {
    $t->pass('->addField() rejects invalid values');
}
$t->diag('testing addMultiTerm()');
$s = inst()->addMultiTerm(range(1, 10), 'foo')->getQuery()->getSubqueries();
$q = new Zend_Search_Lucene_Search_Query_MultiTerm();
foreach (range(1, 10) as $value) {
    $q->addTerm(new Zend_Search_Lucene_Index_Term($value, 'foo'));
}
$t->ok($s[0] == $q, '->addMultiTerm() registers the correct query');
try {
    $s = inst()->addMultiTerm('bar', 'foo')->getQuery()->getSubqueries();
    $q = new Zend_Search_Lucene_Search_Query_MultiTerm();
    $q->addTerm(new Zend_Search_Lucene_Index_Term('bar', 'foo'));
    $t->ok($s[0] == $q, '->addMultiTerm() registers and accepts a string value');
} catch (Exception $e) {
    $t->fail('->addMultiTerm() registers and accepts a string value');
}
$t->diag('testing addWildcard()');
$s = inst()->addWildcard('foo*', 'bar')->getQuery()->getSubqueries();
$q = new Zend_Search_Lucene_Search_Query_Wildcard(new Zend_Search_Lucene_Index_Term('foo*', 'bar'));
$t->ok($s[0] == $q, '->addWildcard() registers the correct query with mutlitple character wildcards');
$s = inst()->addWildcard('f?o', 'bar')->getQuery()->getSubqueries();
$q = new Zend_Search_Lucene_Search_Query_Wildcard(new Zend_Search_Lucene_Index_Term('f?o', 'bar'));
$t->ok($s[0] == $q, '->addWildcard() registers the correct query with single character wildcards');
$s = inst()->addWildcard('foo* baz?', 'bar')->getQuery()->getSubqueries();
$q = new Zend_Search_Lucene_Search_Query_Wildcard(new Zend_Search_Lucene_Index_Term('foo* baz?', 'bar'));
$t->ok($s[0] == $q, '->addWildcard() registers the correct query with mixing character wildcards');
$t->diag('testing addPhrase()');
开发者ID:palcoprincipal,项目名称:sfLucenePlugin,代码行数:31,代码来源:sfLuceneCriteriaTest.php

示例15: _createListTerm

 /**
  * Creates a Lucene query object from a list of values.
  *
  * @param string $name Translated name of the variable or column
  * @param integer $type Type constant
  * @return Zend_Search_Lucene_Search_Query Lucene query object
  */
 protected function _createListTerm($name, $type)
 {
     $sign = null;
     switch ($this->getOperator()) {
         case '!=':
             $sign = false;
         case '==':
             $multiterm = new Zend_Search_Lucene_Search_Query_MultiTerm();
             foreach ($this->getValue() as $value) {
                 $escaped = $this->_escape($this->getOperator(), SORT_STRING, $value);
                 $term = new Zend_Search_Lucene_Index_Term($this->_empty($escaped), $name);
                 $multiterm->addTerm($term, $sign);
             }
             return $multiterm;
         case '~=':
             $query = new Zend_Search_Lucene_Search_Query_Boolean();
             foreach ($this->getValue() as $value) {
                 $escaped = $this->_escape($this->getOperator(), SORT_STRING, $value);
                 $term = new Zend_Search_Lucene_Index_Term(strtolower($this->_empty($escaped)) . '*', $name);
                 $query->addSubquery(new Zend_Search_Lucene_Search_Query_Wildcard($term));
             }
             return $query;
     }
 }
开发者ID:arcavias,项目名称:ext-zend,代码行数:31,代码来源:Lucene.php


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