lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/queryParser QueryParser.jj
Date Thu, 23 Jan 2003 01:28:49 GMT
otis        2003/01/22 17:28:48

  Modified:    src/test/org/apache/lucene/queryParser TestQueryParser.java
               src/java/org/apache/lucene/queryParser QueryParser.jj
  Log:
  - NPE fix.
  PR: bug #16043
  Submitted by: Peter Mularien
  
  Revision  Changes    Path
  1.18      +17 -0     jakarta-lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java
  
  Index: TestQueryParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TestQueryParser.java	13 Jan 2003 23:50:34 -0000	1.17
  +++ TestQueryParser.java	23 Jan 2003 01:28:48 -0000	1.18
  @@ -306,4 +306,21 @@
   	assertQueryEqualsDOA("term +term +term", null, "+term +term +term");
   	assertQueryEqualsDOA("-term term term", null, "-term +term +term");
       }
  +
  +    public void testBoost()
  +        throws Exception
  +    {
  +        StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(new String[]{"on"});
  +        QueryParser qp = new QueryParser("field", oneStopAnalyzer);
  +        Query q = qp.parse("on^1.0");
  +        assertNotNull(q);
  +        q = qp.parse("\"hello\"^2.0");
  +        assertNotNull(q);
  +        assertEquals(q.getBoost(), (float)2.0, (float)0.5);
  +        q = qp.parse("hello^2.0");
  +        assertNotNull(q);
  +        assertEquals(q.getBoost(), (float)2.0, (float)0.5);
  +        q = qp.parse("\"on\"^1.0");
  +        assertNotNull(q);
  +    }
   }
  
  
  
  1.24      +4 -1      jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj
  
  Index: QueryParser.jj
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- QueryParser.jj	13 Jan 2003 23:50:33 -0000	1.23
  +++ QueryParser.jj	23 Jan 2003 01:28:48 -0000	1.24
  @@ -535,7 +535,10 @@
         }
         catch (Exception ignored) { }
   
  -      q.setBoost(f);
  +      // could happen with boosted stopword
  +      if(q != null) {
  +        q.setBoost(f);
  +      }
       }
       return q;
     }
  
  
  

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


Mime
View raw message