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

Modified Files:
        Searcher.java 
Log Message:
LUCENE-12


See also: 
http://cvs.mmbase.org/viewcvs/contributions/lucene/src/org/mmbase/module/lucene
See also: http://www.mmbase.org/jira/browse/LUCENE-12


Index: Searcher.java
===================================================================
RCS file: 
/var/cvs/contributions/lucene/src/org/mmbase/module/lucene/Searcher.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- Searcher.java       21 Jul 2008 14:29:58 -0000      1.48
+++ Searcher.java       21 Jul 2008 16:42:46 -0000      1.49
@@ -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.48 2008/07/21 14:29:58 michiel Exp $
+ * @version $Id: Searcher.java,v 1.49 2008/07/21 16:42:46 michiel Exp $
  * @todo  Should the StopAnalyzers be replaced by index.analyzer? Something 
else?
  **/
 public class Searcher implements NewSearcher.Listener, 
FullIndexEvents.Listener {
@@ -333,6 +333,10 @@
         return s.search(query, filter, sort);
     }
 
+    static final String SYNTAX =
+        "<field>:[ | EQ | GT | GTE | LT | LTE | NE]:<value> | " +
+        "<field>:[IN_SET | NIN_SET]:<value>[,<value2>[,..]] 
| " +
+        "<field>:[IN | INC]:<value1>:<value2>";
 
     static public Filter createFilter(String constraintsText) {
         if (constraintsText == null || "".equals(constraintsText)) return null;
@@ -345,17 +349,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 <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 " + 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 " + 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 " + 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 " + SYNTAX);
                 tokens.nextToken(); // colon
             }
             String value = ""; // should use stringbuffer?
@@ -372,7 +375,7 @@
                 while (tokens.hasMoreTokens()) value += tokens.nextToken();
             }
             Filter subFilter = null;
-            if (type.equals("IN") || type.equals("NIN")) {
+            if (type.equals("IN_SET") || type.equals("NIN_SET")) {
                 subFilter = new TermsFilter();
                 for (String v: value.split(",")) {
                     ((TermsFilter)subFilter).addTerm(new Term(field, v));
@@ -394,7 +397,7 @@
             }
             if (subFilter !=null) {
                 if (filter == null) {
-                    if (type.equals("NE") || type.equals("NIN")) {
+                    if (type.equals("NE") || type.equals("NIN_SET")) {
                         BooleanFilter booleanFilter = new BooleanFilter();
                         booleanFilter.add(new FilterClause(filter, 
BooleanClause.Occur.MUST_NOT));
                         filter = booleanFilter;
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to