lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r605535 - /lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java
Date Wed, 19 Dec 2007 13:36:33 GMT
Author: gsingers
Date: Wed Dec 19 05:36:32 2007
New Revision: 605535

URL: http://svn.apache.org/viewvc?rev=605535&view=rev
Log:
LUCENE-25 added test for stopwords in query parser

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

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java?rev=605535&r1=605534&r2=605535&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java Wed Dec
19 05:36:32 2007
@@ -835,6 +835,22 @@
 
   }
 
+  public void testStopwords() throws Exception {
+    QueryParser qp = new QueryParser("a", new StopAnalyzer(new String[]{"the", "foo"}));
+    Query result = qp.parse("a:the OR a:foo");
+    assertTrue("result is null and it shouldn't be", result != null);
+    assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
+    assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: " + 0, ((BooleanQuery)
result).clauses().size() == 0);
+    result = qp.parse("a:woo OR a:the");
+    assertTrue("result is null and it shouldn't be", result != null);
+    assertTrue("result is not a TermQuery", result instanceof TermQuery);
+    result = qp.parse("(fieldX:xxxxx OR fieldy:xxxxxxxx)^2 AND (fieldx:the OR fieldy:foo)");
+    assertTrue("result is null and it shouldn't be", result != null);
+    assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
+    System.out.println("Result: " + result);
+    assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: " + 2, ((BooleanQuery)
result).clauses().size() == 2);
+  }
+
   public void testMatchAllDocs() throws Exception {
     QueryParser qp = new QueryParser("field", new WhitespaceAnalyzer());
     assertEquals(new MatchAllDocsQuery(), qp.parse("*:*"));



Mime
View raw message