Author: rande
Date: 2010-01-22 19:03:58 +0100 (Fri, 22 Jan 2010)
New Revision: 27064

Modified:
   plugins/sfSolrPlugin/branches/sf1.2/lib/util/sfLuceneCriteria.class.php
   plugins/sfSolrPlugin/branches/sf1.2/test/unit/util/sfLuceneCriteriaTest.php
Log:
[sfSolrPlugin] fix analyser/guesser

Modified: 
plugins/sfSolrPlugin/branches/sf1.2/lib/util/sfLuceneCriteria.class.php
===================================================================
--- plugins/sfSolrPlugin/branches/sf1.2/lib/util/sfLuceneCriteria.class.php     
2010-01-22 17:40:27 UTC (rev 27063)
+++ plugins/sfSolrPlugin/branches/sf1.2/lib/util/sfLuceneCriteria.class.php     
2010-01-22 18:03:58 UTC (rev 27064)
@@ -278,10 +278,10 @@
       $c = new sfLuceneCriteria;
       foreach($phrases as $phrase)
       {
-        $c->addPhrase($phrase, $inner_type);
+        $c->add($sign.'('.self::sanitize($phrase).')', $inner_type, true);
       }
       
-      $this->add($sign.'('.$c->getQuery().')', 'AND', true); 
+      $this->add('('.$c->getQuery().')', 'AND', true); 
     }
     
     return $this;
@@ -313,10 +313,10 @@
       $c = new sfLuceneCriteria;
       foreach($phrases as $phrase)
       {
-        $c->addPhrase($phrase, $inner_type);
+        $c->add($sign.'('.self::sanitize($phrase).')', $type, true);
       }
       
-      $main_criteria->add($sign.'('.$c->getQuery().')', 'AND', true); 
+      $main_criteria->add($c->getQuery(), 'AND', true); 
     }
     
     $this->addField($field, $main_criteria, $type, true);

Modified: 
plugins/sfSolrPlugin/branches/sf1.2/test/unit/util/sfLuceneCriteriaTest.php
===================================================================
--- plugins/sfSolrPlugin/branches/sf1.2/test/unit/util/sfLuceneCriteriaTest.php 
2010-01-22 17:40:27 UTC (rev 27063)
+++ plugins/sfSolrPlugin/branches/sf1.2/test/unit/util/sfLuceneCriteriaTest.php 
2010-01-22 18:03:58 UTC (rev 27064)
@@ -171,27 +171,27 @@
 $t->diag('testing addPhraseGuess()');
 
 $s = inst()->addPhraseGuess('Thomas -"zend framework"')->getQuery();
-$expected = '-("zend framework") AND ("Thomas")';
+$expected = '(-("zend framework")) AND (("Thomas"))';
 $t->cmp_ok($s, '===', $expected, '->addPhraseGuess()');
 
 $s = inst()->addPhraseGuess('"Thomas"   -"zend framework"')->getQuery();
-$expected = '-("zend framework") AND ("Thomas")';
+$expected = '(-("zend framework")) AND (("Thomas"))';
 $t->cmp_ok($s, '===', $expected, '->addPhraseGuess()');
 
 $s = inst()->addPhraseGuess('"Thomas"   -.zend')->getQuery();
-$expected = '-(".zend") AND ("Thomas")';
+$expected = '(-(".zend")) AND (("Thomas"))';
 $t->cmp_ok($s, '===', $expected, '->addPhraseGuess()');
 
 $s = inst()->addPhraseGuess('Thomas Rabaix +"symfony expert" -"zend framework" 
+javascript -.net')->getQuery();
-$expected = '+("symfony expert" AND "javascript") AND -("zend framework" AND 
".net") AND ("Thomas" OR "Rabaix")';
+$expected = '(+("symfony expert") AND +("javascript")) AND (-("zend 
framework") AND -(".net")) AND (("Thomas") OR ("Rabaix"))';
 $t->cmp_ok($s, '===', $expected, '->addPhraseGuess()');
 
 $s = inst()->addPhraseGuess('Thomas Rabaix +"sym"fony expert" -"zen-d 
framework" +javascript -.net')->getQuery();
-$expected = '+("sym" AND "javascript") AND -("zen-d framework" AND ".net") AND 
("Thomas" OR "Rabaix" OR "fony" OR "expert")';
+$expected = '(+("sym") AND +("javascript")) AND (-("zen-d framework") AND 
-(".net")) AND (("Thomas") OR ("Rabaix") OR ("fony") OR ("expert"))';
 $t->cmp_ok($s, '===', $expected, '->addPhraseGuess()');
 
 $s = inst()->addPhraseFieldGuess('name', 'Thomas Rabaix +"sym"fony expert" 
-"zen-d framework" +javascript -.net')->getQuery();
-$expected = 'name:((+("sym" AND "javascript") AND -("zen-d framework" AND 
".net") AND ("Thomas" OR "Rabaix" OR "fony" OR "expert")))';
+$expected = 'name:((+("sym") AND +("javascript") AND -("zen-d framework") AND 
-(".net") AND ("Thomas") AND ("Rabaix") AND ("fony") AND ("expert")))';
 $t->cmp_ok($s, '===', $expected, '->addPhraseGuess()');
 
 

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to