Index: contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/ComposedQuery.java
===================================================================
--- contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/ComposedQuery.java	(revision 1075527)
+++ contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/ComposedQuery.java	(working copy)
@@ -117,5 +117,17 @@
     }
     return false;
   }
+
+// private String opName;
+// private boolean operatorInfix; 
+// private List<SrndQuery> queries;
+
+  @Override
+  public int hashCode() {
+    return super.hashCode() ^ opdistance ^ (ordered ? 256 : 512);
+  }
+
+  @Override
+  public boolean equals(Object obj) {
 }
 
Index: contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndTruncQuery.java
===================================================================
--- contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndTruncQuery.java	(revision 1075527)
+++ contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndTruncQuery.java	(working copy)
@@ -122,4 +122,26 @@
       }
     }
   }
+
+  @Override
+  public int hashCode() {
+    return super.hashCode()
+	^ truncated.hashCode()
+	^ ((int) unlimited)
+	^ ((int) mask);
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == null)
+      return false;
+    if (! (obj instanceof SrndTruncQuery))
+      return false;
+    if (! super.equals(obj))
+      return false;
+    SrndTruncQuery other = (SrndTruncQuery) obj;
+    return truncated.equals(other.truncated)
+	&& (unlimited == other.unlimited)
+	&& (mask == other.mask);
+  }
 }
Index: contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndPrefixQuery.java
===================================================================
--- contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndPrefixQuery.java	(revision 1075527)
+++ contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndPrefixQuery.java	(working copy)
@@ -89,4 +89,23 @@
       }
     }
   }
+
+  @Override
+  public int hashCode() {
+    return super.hashCode()
+	^ prefix.hashCode()
+	^ (int) truncator;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == null)
+      return false;
+    if (! (obj instanceof SrndPrefixQuery))
+      return false;
+    if (! super.equals(obj))
+      return false;
+    SrndPrefixQuery other = (SrndPrefixQuery) obj;
+    return prefix.equals(other.prefix) && (truncator == other.truncator);
+  }
 }
Index: contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/DistanceQuery.java
===================================================================
--- contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/DistanceQuery.java	(revision 1075527)
+++ contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/DistanceQuery.java	(working copy)
@@ -84,7 +84,22 @@
       public Query rewrite(IndexReader reader) throws IOException {
         return getSpanNearQuery(reader, fieldName, getBoost(), qf);
       }
-      
+ 
+      @Override
+      public int hashCode() {
+	return getClass().hashCode() ^ DistanceQuery.this.hashCode();
+      }
+
+      @Override
+      public boolean equals(Object obj) {
+	if (this == obj)
+	  return true;
+	if (obj == null)
+	  return false;
+	if (getClass() != obj.getClass())
+	  return false;
+	return DistanceQuery.this.equals((DistanceQuery)obj));
+      }
     };
   }
   
@@ -101,7 +116,7 @@
       
       ((DistanceSubQuery)sqi.next()).addSpanQueries(sncf);
       if (sncf.size() == 0) { /* distance operator requires all sub queries */
-        while (sqi.hasNext()) { /* produce evt. error messages but ignore results */
+        while (sqi.hasNext()) { /* produce possible error messages but ignore results */
           ((DistanceSubQuery)sqi.next()).addSpanQueries(sncf);
           sncf.clear();
         }
@@ -117,5 +132,22 @@
     r.setBoost(boost);
     return r;
   }
+
+  @Override
+  public int hashCode() {
+    return super.hashCode() ^ opdistance ^ (ordered ? 256 : 512);
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == null)
+      return false;
+    if (! (obj instanceof DistanceQuery))
+      return false;
+    DistanceQuery other = (DistanceQuery) obj;
+    if ((opdistance != other.opdistance) || (ordered != other.ordered))
+      return false;
+    return super.equals(obj);
+  }
 }
 
Index: contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SimpleTerm.java
===================================================================
--- contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SimpleTerm.java	(revision 1075527)
+++ contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SimpleTerm.java	(working copy)
@@ -27,7 +27,7 @@
 
 public abstract class SimpleTerm
   extends SrndQuery
-  implements DistanceSubQuery, Comparable<SimpleTerm>
+  implements DistanceSubQuery
 {
   public SimpleTerm(boolean q) {quoted = q;}
   
@@ -39,11 +39,6 @@
   
   public abstract String toStringUnquoted();
   
-  public int compareTo(SimpleTerm ost) {
-    /* for ordering terms and prefixes before using an index, not used */
-    return this.toStringUnquoted().compareTo( ost.toStringUnquoted());
-  }
-  
   protected void suffixToString(StringBuilder r) {} /* override for prefix query */
   
   @Override
@@ -96,6 +91,22 @@
                   /* luceneSubQueries all have default weight */
                   luceneSubQueries, BooleanClause.Occur.SHOULD); /* OR the subquery terms */ 
       }
+ 
+      @Override
+      public int hashCode() {
+	return getClass().hashCode() ^ SimpleTerm.this.hashCode();
+      }
+
+      @Override
+      public boolean equals(Object obj) {
+	if (this == obj)
+	  return true;
+	if (obj == null)
+	  return false;
+	if (getClass() != obj.getClass())
+	  return false;
+	return SimpleTerm.this.equals((SimpleTerm)obj));
+      }
     };
   }
     
@@ -109,6 +120,21 @@
             }
           });
   }
+
+  @Override
+  public int hashCode() {
+    return getClass().hashCode() ^ (quoted?64:128);
+  }
+  
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == null)
+      return false;
+    if (! (obj instanceof SimpleTerm))
+      return false;
+    SimpleTerm other = (SimpleTerm) obj;
+    return quoted == other.quoted;
+  }
 }
 
 
Index: contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndTermQuery.java
===================================================================
--- contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndTermQuery.java	(revision 1075527)
+++ contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SrndTermQuery.java	(working copy)
@@ -59,6 +59,23 @@
       }
     }
   }
+
+  @Override
+  public int hashCode() {
+    return super.hashCode() ^ termText.hashCode();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == null)
+      return false;
+    if (! (obj instanceof SrndTermQuery))
+      return false;
+    if (! super.equals(obj))
+      return false;
+    SrndTermQuery other = (SrndTermQuery) obj;
+    return termText.equals(other.termText);
+  }
 }
   
 
Index: contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SpanNearClauseFactory.java
===================================================================
--- contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SpanNearClauseFactory.java	(revision 1075527)
+++ contrib/queryparser/src/java/org/apache/lucene/queryParser/surround/query/SpanNearClauseFactory.java	(working copy)
@@ -95,21 +95,12 @@
     weightBySpanQuery.put(sq, w); 
   }
   
-  public void addTermWeighted(Term t, float weight) throws IOException {   
+  public void addTermWeighted(Term t, float weight) throws IOException {
     SpanTermQuery stq = qf.newSpanTermQuery(t);
     /* CHECKME: wrap in Hashable...? */
     addSpanQueryWeighted(stq, weight);
   }
   
-  public void addSpanNearQuery(Query q) {
-    if (q == SrndQuery.theEmptyLcnQuery)
-      return;
-    if (! (q instanceof SpanNearQuery))
-      throw new AssertionError("Expected SpanNearQuery: " + q.toString(getFieldName()));
-    /* CHECKME: wrap in Hashable...? */
-    addSpanQueryWeighted((SpanNearQuery)q, q.getBoost());
-  }
-  
   public SpanQuery makeSpanNearClause() {
     SpanQuery [] spanQueries = new SpanQuery[size()];
     Iterator<SpanQuery> sqi = weightBySpanQuery.keySet().iterator();
