Update of /var/cvs/contributions/lucene/src/org/mmbase/module/lucene
In directory james.mmbase.org:/tmp/cvs-serv23931

Modified Files:
        Searcher.java 
Log Message:
just some cleaning


See also: 
http://cvs.mmbase.org/viewcvs/contributions/lucene/src/org/mmbase/module/lucene


Index: Searcher.java
===================================================================
RCS file: 
/var/cvs/contributions/lucene/src/org/mmbase/module/lucene/Searcher.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- Searcher.java       22 Jul 2008 05:00:29 -0000      1.50
+++ Searcher.java       23 Jul 2008 13:58:48 -0000      1.51
@@ -34,7 +34,7 @@
  * A wrapper around Lucene's [EMAIL PROTECTED] 
org.apache.lucene.search.IndexSearcher}. Every [EMAIL PROTECTED] Indexer} has 
its own Searcher.
  *
  * @author Pierre van Rooden
- * @version $Id: Searcher.java,v 1.50 2008/07/22 05:00:29 michiel Exp $
+ * @version $Id: Searcher.java,v 1.51 2008/07/23 13:58:48 michiel Exp $
  * @todo  Should the StopAnalyzers be replaced by index.analyzer? Something 
else?
  **/
 public class Searcher implements NewSearcher.Listener, 
FullIndexEvents.Listener {
@@ -333,11 +333,14 @@
         return s.search(query, filter, sort);
     }
 
-    static final String SYNTAX =
+    static final String QUERY_SYNTAX =
         "<field>:[ | EQ | GT | GTE | LT | LTE | NE]:<value> | " +
-        "<field>:[IN_SET | NIN_SET]:<value>[,<value2>[,..]] 
| " +
         "<field>:[IN | INC]:<value1>:<value2>";
 
+    static final String FILTER_SYNTAX =
+        QUERY_SYNTAX + " |  <field>:[IN_SET | 
NIN_SET]:<value>[,<value2>[,..]]";
+
+
     static public Filter createFilter(String constraintsText) {
         if (constraintsText == null || "".equals(constraintsText)) return null;
 
@@ -349,16 +352,16 @@
         while (constraints.hasMoreTokens()) {
             String constraint = constraints.nextToken();
             StringTokenizer tokens = new StringTokenizer(constraint, ":", 
true);
-            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + SYNTAX);
+            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + FILTER_SYNTAX);
             String field = tokens.nextToken();
-            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + SYNTAX);
+            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + FILTER_SYNTAX);
             tokens.nextToken(); // colon
-            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + SYNTAX);
+            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + FILTER_SYNTAX);
             String type = tokens.nextToken().toUpperCase();
             if (type.equals(":")) {
                 type = "EQ";
             } else {
-                if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + SYNTAX);
+                if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + FILTER_SYNTAX);
                 tokens.nextToken(); // colon
             }
             String value = ""; // should use stringbuffer?
@@ -407,7 +410,10 @@
                 } else {
                     BooleanFilter booleanFilter = new BooleanFilter();
                     booleanFilter.add(new FilterClause(filter, 
BooleanClause.Occur.MUST));
-                    BooleanClause.Occur occur = type.equals("NE") ? 
BooleanClause.Occur.MUST_NOT : BooleanClause.Occur.MUST;
+                    BooleanClause.Occur occur =
+                        (type.equals("NE") ||
+                         type.equals("NIN_SET"))
+                        ? BooleanClause.Occur.MUST_NOT : 
BooleanClause.Occur.MUST;
                     // no support for 'SHOULD'.
                     booleanFilter.add(new FilterClause(subFilter, occur));
                     filter = booleanFilter;
@@ -433,17 +439,17 @@
         while (constraints.hasMoreTokens()) {
             String constraint = constraints.nextToken();
             StringTokenizer tokens = new StringTokenizer(constraint, ":", 
true);
-            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form <field>:[ | EQ | GT | GTE | LT | LTE | NE | IN | 
INC]:<value>[:<value>]");
+            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + QUERY_SYNTAX);
 
             String field = tokens.nextToken();
-            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form <field>:[ | EQ | GT | GTE | LT | LTE | NE | IN | 
INC]:<value>[:<value>]");
+            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + QUERY_SYNTAX);
             tokens.nextToken(); // colon
-            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form <field>:[ | EQ | GT | GTE | LT | LTE | NE | IN | 
INC]:<value>[:<value>]");
+            if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + QUERY_SYNTAX);
             String type = tokens.nextToken().toUpperCase();
             if (type.equals(":")) {
                 type = "EQ";
             } else {
-                if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form <field>:[ | EQ | GT | GTE | LT | LTE | NE | IN | 
INC]:<value>[:<value>]");
+                if (! tokens.hasMoreTokens()) throw new 
IllegalArgumentException("The constraint '" + constraint + "' is not of the 
form " + QUERY_SYNTAX);
                 tokens.nextToken(); // colon
             }
             String value = ""; // should use stringbuffer?
@@ -483,7 +489,9 @@
                 } else {
                     BooleanQuery booleanQuery = new BooleanQuery();
                     booleanQuery.add(query, BooleanClause.Occur.MUST);
-                    BooleanClause.Occur occur = type.equals("NE") ? 
BooleanClause.Occur.MUST_NOT : BooleanClause.Occur.MUST;
+                    BooleanClause.Occur occur =
+                        type.equals("NE")
+                         ? BooleanClause.Occur.MUST_NOT : 
BooleanClause.Occur.MUST;
                     // no support for 'SHOULD'.
                     booleanQuery.add(subQuery, occur);
                     query = booleanQuery;
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to