public function luceneSearchAetCommunications($index, $searchKeyWord)
 {
     \ZendSearch\Lucene\Analysis\Analyzer\Analyzer::setDefault(new \ZendSearch\Lucene\Analysis\Analyzer\Common\Text\CaseInsensitive());
     $dbIds = array();
     $searchValue = SearchHelper::utf8_to_ascii(mb_strtolower($searchKeyWord, "UTF-8"));
     $em = $this->getDoctrine()->getManager();
     /*
     $term1 = new \ZendSearch\Lucene\Index\Term($searchValue, 'firstname');
     //$subquery1 = new \ZendSearch\Lucene\Search\Query\Term($term1);
     
     $term2 = new \ZendSearch\Lucene\Index\Term($searchValue, 'title');
     //$subquery2 = new \ZendSearch\Lucene\Search\Query\Term($term2);
     
     $term3 = new \ZendSearch\Lucene\Index\Term($searchValue, 'shortdesc');
     //$subquery3 = new \ZendSearch\Lucene\Search\Query\Term($term3);
     
     $term4 = new \ZendSearch\Lucene\Index\Term($searchValue, 'body');
     //$subquery4 = new \ZendSearch\Lucene\Search\Query\Term($term4);
     
     $term5 = new \ZendSearch\Lucene\Index\Term($searchValue, 'author');
     //$subquery5 = new \ZendSearch\Lucene\Search\Query\Term($term5);
     
     
     $terms = array($term1, $term2, $term3, $term4, $term5);
     //$subqueries = array($subquery1, $subquery2, $subquery3, $subquery4, $subquery5);
     $signs = array(null, null, null, null, null);
     
     $termsQuery = new \ZendSearch\Lucene\Search\Query\MultiTerm($terms,$signs);
     */
     \ZendSearch\Lucene\Search\QueryParser::setDefaultOperator(\ZendSearch\Lucene\Search\QueryParser::B_OR);
     $query = \ZendSearch\Lucene\Search\QueryParser::parse($searchValue, 'UTF-8');
     $foundDocuments = $index->find($query);
     //$docNum = count($foundDocuments);
     foreach ($foundDocuments as $foundDoc) {
         $dbIds[] = $foundDoc->dbId;
     }
     $results = $em->getRepository('AetCommunicationBundle:Communication')->findById($dbIds);
     return $results;
 }
Пример #2
0
 /**
  * Normalize Token or remove it (if null is returned)
  *
  * @param Zend_Search_Lucene_Analysis_Token $srcToken
  * @return Zend_Search_Lucene_Analysis_Token
  */
 public function normalize(\ZendSearch\Lucene\Analysis\Token $srcToken)
 {
     $newToken = new \ZendSearch\Lucene\Analysis\Token(SearchHelper::utf8_to_ascii($srcToken->getTermText()), $srcToken->getStartOffset(), $srcToken->getEndOffset());
     $newToken->setPositionIncrement($srcToken->getPositionIncrement());
     return $newToken;
 }
Пример #3
0
 public function luceneSearchAetUsers($index, $searchKeyWord)
 {
     \ZendSearch\Lucene\Analysis\Analyzer\Analyzer::setDefault(new \ZendSearch\Lucene\Analysis\Analyzer\Common\Text\CaseInsensitive());
     $dbIds = array();
     $searchValue = SearchHelper::utf8_to_ascii(mb_strtolower($searchKeyWord, "UTF-8"));
     $em = $this->getDoctrine()->getManager();
     /*
             $term1 = new \ZendSearch\Lucene\Index\Term($searchValue, 'firstname');
             //$subquery1 = new \ZendSearch\Lucene\Search\Query\Term($term1);
     
             $term2 = new \ZendSearch\Lucene\Index\Term($searchValue, 'lastname');
             //$subquery2 = new \ZendSearch\Lucene\Search\Query\Term($term2);
     
             $term3 = new \ZendSearch\Lucene\Index\Term($searchValue, 'activiteprincipale');
             //$subquery3 = new \ZendSearch\Lucene\Search\Query\Term($term3);
     
             $term4 = new \ZendSearch\Lucene\Index\Term($searchValue, 'codepostal');
             //$subquery4 = new \ZendSearch\Lucene\Search\Query\Term($term4);
     
             $term5 = new \ZendSearch\Lucene\Index\Term($searchValue, 'email');
             //$subquery5 = new \ZendSearch\Lucene\Search\Query\Term($term5);
     
             $term6 = new \ZendSearch\Lucene\Index\Term($searchValue, 'matricule');
             //$subquery6 = new \ZendSearch\Lucene\Search\Query\Term($term6);
     
             $term7 = new \ZendSearch\Lucene\Index\Term($searchValue, 'pays');
             //$subquery7 = new \ZendSearch\Lucene\Search\Query\Term($term7);
     
             $term8 = new \ZendSearch\Lucene\Index\Term($searchValue, 'promotion');
             //$subquery8 = new \ZendSearch\Lucene\Search\Query\Term($term8);
     
             $term9 = new \ZendSearch\Lucene\Index\Term($searchValue, 'telephone');
             //$subquery9 = new \ZendSearch\Lucene\Search\Query\Term($term9);
     
             $term10 = new \ZendSearch\Lucene\Index\Term($searchValue, 'ville');
             //$subquery10 = new \ZendSearch\Lucene\Search\Query\Term($term10);
     
             $term11 = new \ZendSearch\Lucene\Index\Term($searchValue, 'whoami');
             //$subquery11 = new \ZendSearch\Lucene\Search\Query\Term($term11);
     
     
             //$subqueries = array($subquery1, $subquery2, $subquery3, $subquery4, $subquery5, $subquery6, $subquery7, $subquery8, $subquery9, $subquery10, $subquery11);
             $terms = array($term1, $term2, $term3, $term4, $term5, $term6, $term7, $term8, $term9, $term10, $term11);
             $signs = array(null, null, null, null, null, null, null, null, null, null, null);
     
     $termsQuery = new \ZendSearch\Lucene\Search\Query\MultiTerm($terms, $signs);
             //$boolQuery = new \ZendSearch\Lucene\Search\Query\Boolean($subqueries, $signs);
     */
     \ZendSearch\Lucene\Search\QueryParser::setDefaultOperator(\ZendSearch\Lucene\Search\QueryParser::B_OR);
     $query = \ZendSearch\Lucene\Search\QueryParser::parse($searchValue, 'UTF-8');
     $foundDocuments = $index->find($query);
     //$docNum = count($foundDocuments);
     foreach ($foundDocuments as $foundDoc) {
         $dbIds[] = $foundDoc->dbId;
     }
     $results = $em->getRepository('AetAnnuaireBundle:User')->findById($dbIds);
     return $results;
 }