Author: magnuse
Date: 2006-04-24 12:43:34 +0200 (Mon, 24 Apr 2006)
New Revision: 2786

Modified:
   
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/AbstractSimpleFastSearchCommand.java
   
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/NewsSearchCommand.java
   
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/WebSearchCommand.java
   branches/2.0/src/javacc/QueryParserImpl.jj
   
branches/2.0/src/test/java/no/schibstedsok/front/searchportal/command/WebSearchCommandTest.java
Log:
Fixed bug that caused exclusion to not work. SEARCH-527.


Modified: 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/AbstractSimpleFastSearchCommand.java
===================================================================
--- 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/AbstractSimpleFastSearchCommand.java
       2006-04-24 10:13:44 UTC (rev 2785)
+++ 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/AbstractSimpleFastSearchCommand.java
       2006-04-24 10:43:34 UTC (rev 2786)
@@ -411,9 +411,9 @@
             final String transformedTerm = (String) getTransformedTerm(clause);
             if (transformedTerm != null && transformedTerm.length() > 0) {
                 if (insideNot) {
-                    appendToQueryRepresentation(" -");
+                    appendToQueryRepresentation("-");
                 }  else if (writeAnd != null && writeAnd.booleanValue()) {
-                    appendToQueryRepresentation(" +");
+                    appendToQueryRepresentation("+");
                 }
                 appendToQueryRepresentation(transformedTerm);
             }

Modified: 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/NewsSearchCommand.java
===================================================================
--- 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/NewsSearchCommand.java
     2006-04-24 10:13:44 UTC (rev 2785)
+++ 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/NewsSearchCommand.java
     2006-04-24 10:43:34 UTC (rev 2786)
@@ -11,8 +11,10 @@
 import java.util.Map;
 import no.schibstedsok.front.searchportal.command.SearchCommand.Context;
 import no.schibstedsok.front.searchportal.query.AndClause;
+import no.schibstedsok.front.searchportal.query.AndNotClause;
 import no.schibstedsok.front.searchportal.query.DefaultOperatorClause;
 import no.schibstedsok.front.searchportal.query.LeafClause;
+import no.schibstedsok.front.searchportal.query.NotClause;
 import no.schibstedsok.front.searchportal.query.OrClause;
 import no.schibstedsok.front.searchportal.query.PhraseClause;
 import no.schibstedsok.front.searchportal.query.XorClause;
@@ -122,6 +124,14 @@
      */
     private final class FilterVisitor extends AbstractReflectionVisitor {
 
+        protected void visitImpl(final NotClause clause) {
+            clause.getFirstClause().accept(this);
+        }
+
+        protected void visitImpl(final AndNotClause clause) {
+            clause.getFirstClause().accept(this);
+        }
+
         protected void visitImpl(final LeafClause clause) {
             if (hasSourceField(clause)) {
                 appendSiteFilter(clause);

Modified: 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/WebSearchCommand.java
===================================================================
--- 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/WebSearchCommand.java
      2006-04-24 10:13:44 UTC (rev 2785)
+++ 
branches/2.0/src/java/no/schibstedsok/front/searchportal/command/WebSearchCommand.java
      2006-04-24 10:43:34 UTC (rev 2786)
@@ -10,8 +10,10 @@
 
 import java.util.Map;
 import no.schibstedsok.front.searchportal.query.AndClause;
+import no.schibstedsok.front.searchportal.query.AndNotClause;
 import no.schibstedsok.front.searchportal.query.DefaultOperatorClause;
 import no.schibstedsok.front.searchportal.query.LeafClause;
+import no.schibstedsok.front.searchportal.query.NotClause;
 import no.schibstedsok.front.searchportal.query.OrClause;
 import no.schibstedsok.front.searchportal.query.PhraseClause;
 import no.schibstedsok.front.searchportal.query.XorClause;
@@ -107,6 +109,14 @@
             }
         }
 
+        protected void visitImpl(final NotClause clause) {
+            clause.getFirstClause().accept(this);
+        }
+
+        protected void visitImpl(final AndNotClause clause) {
+            clause.getFirstClause().accept(this);
+        }
+
         protected void visitImpl(final PhraseClause clause) {
             if (hasSiteField(clause)) {
                 appendSiteFilter(clause);

Modified: branches/2.0/src/javacc/QueryParserImpl.jj
===================================================================
--- branches/2.0/src/javacc/QueryParserImpl.jj  2006-04-24 10:13:44 UTC (rev 
2785)
+++ branches/2.0/src/javacc/QueryParserImpl.jj  2006-04-24 10:43:34 UTC (rev 
2786)
@@ -74,7 +74,8 @@
 <*>SKIP : {
       " " | "!" 
     | < [ "\u0023"-"\u0027" ] >
-    | < [ "\u002a"-"\u002f" ] >
+    | < [ "\u002a"-"\u002c" ] >
+    | < [ "\u002e"-"\u002f" ] >
     | < [ "\u003b"-"\u0040" ] >
     | < [ "\u005b"-"\u0060" ] >
     | < [ "\u007b"-"\u00bf" ] >

Modified: 
branches/2.0/src/test/java/no/schibstedsok/front/searchportal/command/WebSearchCommandTest.java
===================================================================
--- 
branches/2.0/src/test/java/no/schibstedsok/front/searchportal/command/WebSearchCommandTest.java
     2006-04-24 10:13:44 UTC (rev 2785)
+++ 
branches/2.0/src/test/java/no/schibstedsok/front/searchportal/command/WebSearchCommandTest.java
     2006-04-24 10:43:34 UTC (rev 2786)
@@ -74,12 +74,28 @@
                 "bil",
                 "");
     }
+
+    public void testExclusion() {
+        executeTestOfQuery("magnus -eklund",
+                "magnus -eklund",
+                "");
+        executeTestOfQuery("-whatever",
+                "-whatever",
+                "");
+    }
+
     
+    public void testTwoTerms() {
+        executeTestOfQuery("magnus eklund",
+                "magnus eklund",
+                "");
+    }
+    
     /**
      *
      *
      */
-    public void testExclusion() {
+    public void testSiteExclusion() {
 //        executeTestOfQuery(
 //                "-site:zmag.org bil",
 //                "bil",

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to