lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gol...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/queryParser QueryParser.jj QueryParser.java
Date Tue, 12 Oct 2004 09:36:13 GMT
goller      2004/10/12 02:36:13

  Modified:    src/java/org/apache/lucene/queryParser QueryParser.jj
                        QueryParser.java
  Log:
  Reinsert old API for getFieldQuery, getRangeQuery, and
  getFuzzyQuery and deprecate it.
  
  Revision  Changes    Path
  1.53      +57 -5     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.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- QueryParser.jj	10 Oct 2004 18:43:18 -0000	1.52
  +++ QueryParser.jj	12 Oct 2004 09:36:12 -0000	1.53
  @@ -291,6 +291,19 @@
       else
         throw new RuntimeException("Clause cannot be both required and prohibited");
     }
  +  
  +  /**
  +   * Note that parameter analyzer is ignored. Calls inside the parser always
  +   * use class member analyzer.
  +   *
  +   * @exception ParseException throw in overridden method to disallow
  +   * @deprecated use {@link #getFieldQuery(String, String)}
  +   */
  +  protected Query getFieldQuery(String field,
  +                                                    Analyzer analyzer,
  +                                                    String queryText)  throws ParseException
{
  +    return getFieldQuery(field, queryText);
  +  }
   
     /**
      * @exception ParseException throw in overridden method to disallow
  @@ -335,6 +348,20 @@
         return q;
       }
     }
  +  
  +  /**
  +   * Note that parameter analyzer is ignored. Calls inside the parser always
  +   * use class member analyzer.
  +   *
  +   * @exception ParseException throw in overridden method to disallow
  +   * @deprecated use {@link #getFieldQuery(String, String, int)}
  +   */
  +  protected Query getFieldQuery(String field,
  +                                                    Analyzer analyzer,
  +                                                    String queryText,
  +                                                    int slop) throws ParseException {
  +    return getFieldQuery(field, queryText, slop);
  +  }
   
     /**
      * Base implementation delegates to {@link #getFieldQuery(String,String)}.
  @@ -353,6 +380,21 @@
   
       return query;
     }
  +  
  +  /**
  +   * Note that parameter analyzer is ignored. Calls inside the parser always
  +   * use class member analyzer.
  +   *
  +   * @exception ParseException throw in overridden method to disallow
  +   * @deprecated use {@link #getRangeQuery(String, String, String, boolean)}
  +   */
  +  protected Query getRangeQuery(String field,
  +      Analyzer analyzer,
  +      String part1,
  +      String part2,
  +      boolean inclusive) throws ParseException {
  +    return getRangeQuery(field, part1, part2, inclusive);
  +  }
   
     /**
      * @exception ParseException throw in overridden method to disallow
  @@ -461,6 +503,13 @@
       return new PrefixQuery(t);
     }
     
  + /**
  +   * @deprecated use {@link #getFuzzyQuery(String, String, float)}
  +   */
  +  protected Query getFuzzyQuery(String field, String termStr) throws ParseException {
  +    return getFuzzyQuery(field, termStr, fuzzyMinSim);
  +  }
  +  
      /**
      * Factory method for generating a query (similar to
      * ({@link #getWildcardQuery}). Called when parser parses
  @@ -706,9 +755,12 @@
          	 if(fms < 0.0f || fms > 1.0f){
          	   throw new ParseException("Minimum similarity for a FuzzyQuery has to be between
0.0f and 1.0f !");
          	 }
  -         q = getFuzzyQuery(field, termImage, fms);
  +       	 if(fms == fuzzyMinSim)
  +       	   q = getFuzzyQuery(field, termImage);
  +       	 else
  +           q = getFuzzyQuery(field, termImage, fms);
          } else {
  -         q = getFieldQuery(field, termImage);
  +         q = getFieldQuery(field, analyzer, termImage);
          }
        }
        | ( <RANGEIN_START> ( goop1=<RANGEIN_GOOP>|goop1=<RANGEIN_QUOTED>
)
  @@ -726,7 +778,7 @@
         } else {
           goop2.image = discardEscapeChar(goop2.image);
         }
  -          q = getRangeQuery(field, goop1.image, goop2.image, true);
  +          q = getRangeQuery(field, analyzer, goop1.image, goop2.image, true);
           }
        | ( <RANGEEX_START> ( goop1=<RANGEEX_GOOP>|goop1=<RANGEEX_QUOTED>
)
            [ <RANGEEX_TO> ] ( goop2=<RANGEEX_GOOP>|goop2=<RANGEEX_QUOTED>
)
  @@ -744,7 +796,7 @@
           goop2.image = discardEscapeChar(goop2.image);
         }
   
  -          q = getRangeQuery(field, goop1.image, goop2.image, false);
  +          q = getRangeQuery(field, analyzer, goop1.image, goop2.image, false);
           }
        | term=<QUOTED>
          [ fuzzySlop=<FUZZY_SLOP> ]
  @@ -758,7 +810,7 @@
              }
              catch (Exception ignored) { }
            }
  -         q = getFieldQuery(field, term.image.substring(1, term.image.length()-1), s);
  +         q = getFieldQuery(field, analyzer, term.image.substring(1, term.image.length()-1),
s);
          }
     )
     {
  
  
  
  1.19      +58 -6     jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.java
  
  Index: QueryParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- QueryParser.java	6 Oct 2004 16:19:51 -0000	1.18
  +++ QueryParser.java	12 Oct 2004 09:36:12 -0000	1.19
  @@ -270,6 +270,19 @@
     }
   
     /**
  +   * Note that parameter analyzer is ignored. Calls inside the parser always
  +   * use class member analyzer.
  +   *
  +   * @exception ParseException throw in overridden method to disallow
  +   * @deprecated use {@link #getFieldQuery(String, String)}
  +   */
  +  protected Query getFieldQuery(String field,
  +                                                    Analyzer analyzer,
  +                                                    String queryText)  throws ParseException
{
  +    return getFieldQuery(field, queryText);
  +  }
  +
  +  /**
      * @exception ParseException throw in overridden method to disallow
      */
     protected Query getFieldQuery(String field, String queryText)  throws ParseException
{
  @@ -314,6 +327,20 @@
     }
   
     /**
  +   * Note that parameter analyzer is ignored. Calls inside the parser always
  +   * use class member analyzer.
  +   *
  +   * @exception ParseException throw in overridden method to disallow
  +   * @deprecated use {@link #getFieldQuery(String, String, int)}
  +   */
  +  protected Query getFieldQuery(String field,
  +                                                    Analyzer analyzer,
  +                                                    String queryText,
  +                                                    int slop) throws ParseException {
  +    return getFieldQuery(field, queryText, slop);
  +  }
  +
  +  /**
      * Base implementation delegates to {@link #getFieldQuery(String,String)}.
      * This method may be overridden, for example, to return
      * a SpanNearQuery instead of a PhraseQuery.
  @@ -332,6 +359,21 @@
     }
   
     /**
  +   * Note that parameter analyzer is ignored. Calls inside the parser always
  +   * use class member analyzer.
  +   *
  +   * @exception ParseException throw in overridden method to disallow
  +   * @deprecated use {@link #getRangeQuery(String, String, String, boolean)}
  +   */
  +  protected Query getRangeQuery(String field,
  +      Analyzer analyzer,
  +      String part1,
  +      String part2,
  +      boolean inclusive) throws ParseException {
  +    return getRangeQuery(field, part1, part2, inclusive);
  +  }
  +
  +  /**
      * @exception ParseException throw in overridden method to disallow
      */
     protected Query getRangeQuery(String field,
  @@ -438,6 +480,13 @@
       return new PrefixQuery(t);
     }
   
  + /**
  +   * @deprecated use {@link #getFuzzyQuery(String, String, float)}
  +   */
  +  protected Query getFuzzyQuery(String field, String termStr) throws ParseException {
  +    return getFuzzyQuery(field, termStr, fuzzyMinSim);
  +  }
  +
      /**
      * Factory method for generating a query (similar to
      * ({@link #getWildcardQuery}). Called when parser parses
  @@ -473,7 +522,7 @@
   
     /**
      * Returns a String where those characters that QueryParser
  -   * expects to be escaped are escaped, i.e. preceded by a <code>\</code>.
  +   * expects to be escaped are escaped by a preceding <code>\</code>.
      */
     public static String escape(String s) {
       StringBuffer sb = new StringBuffer();
  @@ -728,9 +777,12 @@
            if(fms < 0.0f || fms > 1.0f){
              {if (true) throw new ParseException("Minimum similarity for a FuzzyQuery has
to be between 0.0f and 1.0f !");}
            }
  -         q = getFuzzyQuery(field, termImage, fms);
  +         if(fms == fuzzyMinSim)
  +           q = getFuzzyQuery(field, termImage);
  +         else
  +           q = getFuzzyQuery(field, termImage, fms);
          } else {
  -         q = getFieldQuery(field, termImage);
  +         q = getFieldQuery(field, analyzer, termImage);
          }
         break;
       case RANGEIN_START:
  @@ -787,7 +839,7 @@
         } else {
           goop2.image = discardEscapeChar(goop2.image);
         }
  -          q = getRangeQuery(field, goop1.image, goop2.image, true);
  +          q = getRangeQuery(field, analyzer, goop1.image, goop2.image, true);
         break;
       case RANGEEX_START:
         jj_consume_token(RANGEEX_START);
  @@ -844,7 +896,7 @@
           goop2.image = discardEscapeChar(goop2.image);
         }
   
  -          q = getRangeQuery(field, goop1.image, goop2.image, false);
  +          q = getRangeQuery(field, analyzer, goop1.image, goop2.image, false);
         break;
       case QUOTED:
         term = jj_consume_token(QUOTED);
  @@ -873,7 +925,7 @@
              }
              catch (Exception ignored) { }
            }
  -         q = getFieldQuery(field, term.image.substring(1, term.image.length()-1), s);
  +         q = getFieldQuery(field, analyzer, term.image.substring(1, term.image.length()-1),
s);
         break;
       default:
         jj_la1[21] = jj_gen;
  
  
  

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