After submitting the term collector patch I realized that the patch probably 
should be broken into two pieces:  one that contains base changes to Query 
classes, and that are likely to be needed no matter how Terms are collected, 
and second that contains other code built on top of normal query classes 
(query iterator, term iterators).
This way patches can be evaluated separately.

Attached is included set of patches to core Query classes that are not 
specific to term collector idea.

Here's the quick rundown on changes:

BooleanClause:
  - added 'getQuery()' to be able to access Query contained in boolean clause
    (query member variable is public, but I think access should be done via
    get-method, and member variable could if need be changed to private)

PrefixQuery:
  - added 'getTerm()' for accessing unexpanded base term.

Query:
  - added 'hasBoost()' that's equivalent to 'return (boots != 1.0f)'. I think 
    it's better to use this method instead of comparing to a well-known
   constant, although I didn't at this point change those calls.

RangeQuery:
  - added 'getLowerTerm()' and 'getUpperTerm()', to be able to access
   unexpanded base terms that define range.
 - added 'isInclusive()' for accessing 'inclusive' flag that indicates whether
   limit Terms themselves are to be included in the range to match terms.
- changed 'getField()' from private to public. It might be a good idea to 
  require all Query classes to define 'getField()' method, but I didn't do
  that yet. (it is possible to access field data through various getTerm()
  methods, and then check Term's field... but the way to do that is 
  query type specific).

-+ Tatu +-

Index: search/BooleanClause.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/search/BooleanClause.java,v
retrieving revision 1.5
diff -u -r1.5 BooleanClause.java
--- search/BooleanClause.java   13 Jan 2003 23:50:33 -0000      1.5
+++ search/BooleanClause.java   16 Mar 2003 04:16:53 -0000
@@ -83,6 +83,10 @@
       && (this.prohibited == other.prohibited);
   }
 
+  public Query getQuery() {
+    return query;
+  }
+
   /** Returns a hash code value for this object.*/
   public int hashCode() {
     return query.hashCode() ^ (this.required?1:0) ^ (this.prohibited?2:0);
Index: search/PrefixQuery.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/search/PrefixQuery.java,v
retrieving revision 1.6
diff -u -r1.6 PrefixQuery.java
--- search/PrefixQuery.java     29 Jan 2003 17:18:55 -0000      1.6
+++ search/PrefixQuery.java     16 Mar 2003 04:16:54 -0000
@@ -98,6 +98,10 @@
     return Query.mergeBooleanQueries(queries);
   }
 
+  public Term getTerm() {
+    return prefix;
+  }
+
   /** Prints a user-readable version of this query. */
   public String toString(String field) {
     StringBuffer buffer = new StringBuffer();
Index: search/Query.java
===================================================================
RCS file: /home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/search/Query.java,v
retrieving revision 1.12
diff -u -r1.12 Query.java
--- search/Query.java   20 Jan 2003 18:40:19 -0000      1.12
+++ search/Query.java   16 Mar 2003 04:16:54 -0000
@@ -93,6 +93,14 @@
    */
   public float getBoost() { return boost; }
 
+  /** Checks whether Query has an explicit boost, that is, something other
+   * than default boost of 1.0.
+   *
+   * @return True if query has explicit boost different from default
+   *   boost value; false otherwise.
+   */
+  public boolean hasBoost() { return boost != 1.0f; }
+
   /** 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 [EMAIL 
PROTECTED]
    * org.apache.lucene.queryParser.QueryParser QueryParser} (although, if the
Index: search/RangeQuery.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/search/RangeQuery.java,v
retrieving revision 1.7
diff -u -r1.7 RangeQuery.java
--- search/RangeQuery.java      29 Jan 2003 17:18:55 -0000      1.7
+++ search/RangeQuery.java      16 Mar 2003 04:16:54 -0000
@@ -88,6 +88,10 @@
         this.inclusive = inclusive;
     }
 
+    public Term getLowerTerm() { return lowerTerm; }
+    public Term getUpperTerm() { return upperTerm; }
+    public boolean isInclusive() { return inclusive; }
+
     public Query rewrite(IndexReader reader) throws IOException {
       BooleanQuery query = new BooleanQuery();
       // if we have a lowerTerm, start there. otherwise, start at beginning
@@ -140,7 +144,7 @@
       return Query.mergeBooleanQueries(queries);
     }
 
-    private String getField()
+    public String getField()
     {
         return (lowerTerm != null ? lowerTerm.field() : upperTerm.field());
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to