lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject cvs commit: jakarta-lucene/src/test/org/apache/lucene/queryParser TestQueryParser.java
Date Mon, 06 Sep 2004 22:09:13 GMT
dnaber      2004/09/06 15:09:13

  Modified:    src/java/org/apache/lucene/search Query.java TermQuery.java
               src/test/org/apache/lucene/queryParser TestQueryParser.java
  Log:
  Undo my fix for bug 30985, as it fixes only part of the problem. Instead add a comment about
this "bug" to the API documentation.
  
  Revision  Changes    Path
  1.17      +11 -4     jakarta-lucene/src/java/org/apache/lucene/search/Query.java
  
  Index: Query.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/Query.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Query.java	2 Mar 2004 13:48:10 -0000	1.16
  +++ Query.java	6 Sep 2004 22:09:13 -0000	1.17
  @@ -58,10 +58,17 @@
     public float getBoost() { return boost; }
   
     /** Prints a query to a string, with <code>field</code> as the default field
  -   * for terms.  <p>The representation used is one that is readable by
  -   * {@link org.apache.lucene.queryParser.QueryParser QueryParser}
  -   * (although, if the query was created by the parser, the printed
  -   * representation may not be exactly what was parsed).
  +   * for terms.  <p>The representation used is one that is supposed to be readable
  +   * by {@link org.apache.lucene.queryParser.QueryParser QueryParser}. However,
  +   * there are the following limitations:
  +   * <ul>
  +   *  <li>If the query was created by the parser, the printed
  +   *  representation may not be exactly what was parsed. For example,
  +   *  characters that need to be escaped will be represented without
  +   *  the required backslash.</li>
  +   * <li>Some of the more complicated queries (e.g. span queries)
  +   *  don't have a representation that can be parsed by QueryParser.</li>
  +   * </ul>
      */
     public abstract String toString(String field);
   
  
  
  
  1.13      +2 -3      jakarta-lucene/src/java/org/apache/lucene/search/TermQuery.java
  
  Index: TermQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/TermQuery.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- TermQuery.java	3 Sep 2004 21:12:22 -0000	1.12
  +++ TermQuery.java	6 Sep 2004 22:09:13 -0000	1.13
  @@ -20,7 +20,6 @@
   import org.apache.lucene.index.Term;
   import org.apache.lucene.index.TermDocs;
   import org.apache.lucene.index.IndexReader;
  -import org.apache.lucene.queryParser.QueryParser;
   
   /** A Query that matches documents containing a term.
     This may be combined with other terms with a {@link BooleanQuery}.
  @@ -143,10 +142,10 @@
     public String toString(String field) {
       StringBuffer buffer = new StringBuffer();
       if (!term.field().equals(field)) {
  -      buffer.append(QueryParser.escape(term.field()));
  +      buffer.append(term.field());
         buffer.append(":");
       }
  -    buffer.append(QueryParser.escape(term.text()));
  +    buffer.append(term.text());
       if (getBoost() != 1.0f) {
         buffer.append("^");
         buffer.append(Float.toString(getBoost()));
  
  
  
  1.29      +13 -14    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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- TestQueryParser.java	3 Sep 2004 21:16:28 -0000	1.28
  +++ TestQueryParser.java	6 Sep 2004 22:09:13 -0000	1.29
  @@ -317,7 +317,8 @@
   
     public void testEscaped() throws Exception {
       Analyzer a = new WhitespaceAnalyzer();
  -    assertQueryEquals("\\[brackets", a, "\\[brackets");
  +    
  +    /*assertQueryEquals("\\[brackets", a, "\\[brackets");
       assertQueryEquals("\\[brackets", null, "brackets");
       assertQueryEquals("\\\\", a, "\\\\");
       assertQueryEquals("\\+blah", a, "\\+blah");
  @@ -337,21 +338,19 @@
       assertQueryEquals("\\~blah", a, "\\~blah");
       assertQueryEquals("\\*blah", a, "\\*blah");
       assertQueryEquals("\\?blah", a, "\\?blah");
  -    
  -    // TODO: what about these?
       //assertQueryEquals("foo \\&\\& bar", a, "foo \\&\\& bar");
       //assertQueryEquals("foo \\|| bar", a, "foo \\|| bar");
  -    //assertQueryEquals("foo \\AND bar", a, "foo \\AND bar");
  +    //assertQueryEquals("foo \\AND bar", a, "foo \\AND bar");*/
   
  -    assertQueryEquals("a\\-b:c", a, "a\\-b:c");
  -    assertQueryEquals("a\\+b:c", a, "a\\+b:c");
  -    assertQueryEquals("a\\:b:c", a, "a\\:b:c");
  -    assertQueryEquals("a\\\\b:c", a, "a\\\\b:c");
  -
  -    assertQueryEquals("a:b\\-c", a, "a:b\\-c");
  -    assertQueryEquals("a:b\\+c", a, "a:b\\+c");
  -    assertQueryEquals("a:b\\:c", a, "a:b\\:c");
  -    assertQueryEquals("a:b\\\\c", a, "a:b\\\\c");
  +    assertQueryEquals("a\\-b:c", a, "a-b:c");
  +    assertQueryEquals("a\\+b:c", a, "a+b:c");
  +    assertQueryEquals("a\\:b:c", a, "a:b:c");
  +    assertQueryEquals("a\\\\b:c", a, "a\\b:c");
  +
  +    assertQueryEquals("a:b\\-c", a, "a:b-c");
  +    assertQueryEquals("a:b\\+c", a, "a:b+c");
  +    assertQueryEquals("a:b\\:c", a, "a:b:c");
  +    assertQueryEquals("a:b\\\\c", a, "a:b\\c");
   
       assertQueryEquals("a:b\\-c*", a, "a:b-c*");
       assertQueryEquals("a:b\\+c*", a, "a:b+c*");
  @@ -363,7 +362,7 @@
       assertQueryEquals("a:b\\+?c", a, "a:b+?c");
       assertQueryEquals("a:b\\:?c", a, "a:b:?c");
   
  -    assertQueryEquals("a:b\\\\?c", a, "a:b\\\\\\?c");
  +    assertQueryEquals("a:b\\\\?c", a, "a:b\\?c");
   
       assertQueryEquals("a:b\\-c~", a, "a:b-c~");
       assertQueryEquals("a:b\\+c~", a, "a:b+c~");
  
  
  

---------------------------------------------------------------------
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