lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject svn commit: r154406 - in lucene/java/trunk/src: java/org/apache/lucene/queryParser/MultiFieldQueryParser.java test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
Date Sat, 19 Feb 2005 15:04:51 GMT
Author: dnaber
Date: Sat Feb 19 07:04:49 2005
New Revision: 154406

URL: http://svn.apache.org/viewcvs?view=rev&rev=154406
Log:
fix NullPointerException when parsing phrase query with the new MFQP

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/queryParser/MultiFieldQueryParser.java
    lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/MultiFieldQueryParser.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/queryParser/MultiFieldQueryParser.java?view=diff&r1=154405&r2=154406
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/MultiFieldQueryParser.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/MultiFieldQueryParser.java Sat
Feb 19 07:04:49 2005
@@ -57,6 +57,17 @@
     this.fields = fields;
   }
   
+  protected Query getFieldQuery(String field, String queryText) throws ParseException {
+    if (field == null) {
+      Vector clauses = new Vector();
+      for (int i = 0; i < fields.length; i++)
+        clauses.add(new BooleanClause(super.getFieldQuery(fields[i], queryText),
+            BooleanClause.Occur.SHOULD));
+      return getBooleanQuery(clauses);
+    }
+    return super.getFieldQuery(field, queryText);
+  }
+  
   protected Query getFieldQuery(String field, Analyzer analyzer, String queryText)
       throws ParseException {
     if (field == null) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java?view=diff&r1=154405&r2=154406
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
(original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
Sat Feb 19 07:04:49 2005
@@ -58,6 +58,12 @@
     q = mfqp.parse("[a TO c] two");
     assertEquals("(b:[a TO c] t:[a TO c]) (b:two t:two)", q.toString());
 
+    q = mfqp.parse("\"foo bar\"");
+    assertEquals("b:\"foo bar\" t:\"foo bar\"", q.toString());
+
+    q = mfqp.parse("\"aa bb cc\" \"dd ee\"");
+    assertEquals("(b:\"aa bb cc\" t:\"aa bb cc\") (b:\"dd ee\" t:\"dd ee\")", q.toString());
+
     // make sure that terms which have a field are not touched:
     q = mfqp.parse("one f:two");
     assertEquals("(b:one t:one) f:two", q.toString());
@@ -66,6 +72,8 @@
     mfqp.setDefaultOperator(QueryParser.AND_OPERATOR);
     q = mfqp.parse("one two");
     assertEquals("+(b:one t:one) +(b:two t:two)", q.toString());
+    q = mfqp.parse("\"aa bb cc\" \"dd ee\"");
+    assertEquals("+(b:\"aa bb cc\" t:\"aa bb cc\") +(b:\"dd ee\" t:\"dd ee\")", q.toString());
 
   }
   



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message