You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ar...@apache.org on 2006/08/17 15:49:32 UTC

svn commit: r432239 [5/8] - in /incubator/lucene.net/trunk/C#/src: ./ Demo/DeleteFiles/ Demo/DemoLib/ Demo/DemoLib/HTML/ Demo/IndexFiles/ Demo/IndexHtml/ Demo/SearchFiles/ Lucene.Net/ Lucene.Net/Analysis/ Lucene.Net/Analysis/Standard/ Lucene.Net/Docume...

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCacheImpl.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/FieldCacheImpl.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCacheImpl.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCacheImpl.cs Thu Aug 17 06:49:26 2006
@@ -19,7 +19,7 @@
 using Term = Lucene.Net.Index.Term;
 using TermDocs = Lucene.Net.Index.TermDocs;
 using TermEnum = Lucene.Net.Index.TermEnum;
-using StringIndex = Lucene.Net.Search.StringIndex;
+using StringIndex = Lucene.Net.Search.StringIndex; // required by GCJ
 
 namespace Lucene.Net.Search
 {
@@ -59,14 +59,16 @@
 			internal System.String field; // which Field
 			internal int type; // which SortField type
 			internal System.Object custom; // which custom comparator
+            internal System.Globalization.CultureInfo locale; // the locale we're sorting (if string)
 			
 			/// <summary>Creates one of these objects. </summary>
-			internal Entry(System.String field, int type)
+			internal Entry(System.String field, int type, System.Globalization.CultureInfo locale)
 			{
 				this.field = String.Intern(field);
 				this.type = type;
 				this.custom = null;
-			}
+                this.locale = locale;
+            }
 			
 			/// <summary>Creates one of these objects for a custom comparator. </summary>
 			internal Entry(System.String field, System.Object custom)
@@ -74,7 +76,8 @@
 				this.field = String.Intern(field);
 				this.type = SortField.CUSTOM;
 				this.custom = custom;
-			}
+                this.locale = null;
+            }
 			
 			/// <summary>Two of these are equal iff they reference the same field and type. </summary>
 			public  override bool Equals(System.Object o)
@@ -84,15 +87,18 @@
 					Entry other = (Entry) o;
 					if (other.field == field && other.type == type)
 					{
-						if (other.custom == null)
-						{
-							if (custom == null)
-								return true;
-						}
-						else if (other.custom.Equals(custom))
-						{
-							return true;
-						}
+                        if (other.locale == null ? locale == null : other.locale.Equals(locale))
+                        {
+                            if (other.custom == null)
+                            {
+                                if (custom == null)
+                                    return true;
+                            }
+                            else if (other.custom.Equals(custom))
+                            {
+                                return true;
+                            }
+                        }
 					}
 				}
 				return false;
@@ -101,7 +107,7 @@
 			/// <summary>Composes a hashcode based on the field and type. </summary>
 			public override int GetHashCode()
 			{
-				return field.GetHashCode() ^ type ^ (custom == null?0:custom.GetHashCode());
+				return field.GetHashCode() ^ type ^ (custom == null ? 0 : custom.GetHashCode()) ^ (locale == null ? 0 : locale.GetHashCode());
 			}
 		}
 		
@@ -113,9 +119,9 @@
 		internal System.Collections.IDictionary cache = new System.Collections.Hashtable();
 		
 		/// <summary>See if an object is in the cache. </summary>
-		internal virtual System.Object Lookup(IndexReader reader, System.String field, int type)
+		internal virtual System.Object Lookup(IndexReader reader, System.String field, int type, System.Globalization.CultureInfo locale)
 		{
-			Entry entry = new Entry(field, type);
+			Entry entry = new Entry(field, type, locale);
 			lock (this)
 			{
 				System.Collections.Hashtable readerCache = (System.Collections.Hashtable) cache[reader];
@@ -139,9 +145,9 @@
 		}
 		
 		/// <summary>Put an object into the cache. </summary>
-		internal virtual System.Object Store(IndexReader reader, System.String field, int type, System.Object value_Renamed)
+		internal virtual System.Object Store(IndexReader reader, System.String field, int type, System.Globalization.CultureInfo locale, System.Object value_Renamed)
 		{
-			Entry entry = new Entry(field, type);
+			Entry entry = new Entry(field, type, locale);
 			lock (this)
 			{
 				System.Collections.Hashtable readerCache = (System.Collections.Hashtable) cache[reader];
@@ -190,35 +196,28 @@
 			if (ret == null)
 			{
 				int[] retArray = new int[reader.MaxDoc()];
-				if (retArray.Length > 0)
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				try
 				{
-					TermDocs termDocs = reader.TermDocs();
-					TermEnum termEnum = reader.Terms(new Term(field, ""));
-					try
+					do 
 					{
-						if (termEnum.Term() == null)
-						{
-							throw new System.SystemException("no terms in field " + field);
-						}
-						do 
+						Term term = termEnum.Term();
+						if (term == null || term.Field() != field)
+							break;
+						int termval = parser.ParseInt(term.Text());
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
 						{
-							Term term = termEnum.Term();
-							if (term.Field() != field)
-								break;
-							int termval = parser.ParseInt(term.Text());
-							termDocs.Seek(termEnum);
-							while (termDocs.Next())
-							{
-								retArray[termDocs.Doc()] = termval;
-							}
+							retArray[termDocs.Doc()] = termval;
 						}
-						while (termEnum.Next());
-					}
-					finally
-					{
-						termDocs.Close();
-						termEnum.Close();
 					}
+					while (termEnum.Next());
+				}
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
 				}
 				Store(reader, field, parser, retArray);
 				return retArray;
@@ -240,43 +239,36 @@
 			if (ret == null)
 			{
 				float[] retArray = new float[reader.MaxDoc()];
-				if (retArray.Length > 0)
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				try
 				{
-					TermDocs termDocs = reader.TermDocs();
-					TermEnum termEnum = reader.Terms(new Term(field, ""));
-					try
+					do 
 					{
-						if (termEnum.Term() == null)
-						{
-							throw new System.SystemException("no terms in field " + field);
-						}
-						do 
+						Term term = termEnum.Term();
+						if (term == null || term.Field() != field)
+							break;
+						float termval;
+                        try
+                        {
+                            termval = SupportClass.Single.Parse(term.Text());
+                        }
+                        catch (Exception e)
+                        {
+                            termval = 0;
+                        }
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
 						{
-							Term term = termEnum.Term();
-							if (term.Field() != field)
-								break;
-							float termval;
-                            try
-                            {
-                                termval = SupportClass.Single.Parse(term.Text());
-                            }
-                            catch (Exception e)
-                            {
-                                termval = 0;
-                            }
-							termDocs.Seek(termEnum);
-							while (termDocs.Next())
-							{
-								retArray[termDocs.Doc()] = termval;
-							}
+							retArray[termDocs.Doc()] = termval;
 						}
-						while (termEnum.Next());
-					}
-					finally
-					{
-						termDocs.Close();
-						termEnum.Close();
 					}
+					while (termEnum.Next());
+				}
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
 				}
 				Store(reader, field, parser, retArray);
 				return retArray;
@@ -288,41 +280,34 @@
 		public virtual System.String[] GetStrings(IndexReader reader, System.String field)
 		{
 			field = String.Intern(field);
-			System.Object ret = Lookup(reader, field, SortField.STRING);
+			System.Object ret = Lookup(reader, field, SortField.STRING, null);
 			if (ret == null)
 			{
 				System.String[] retArray = new System.String[reader.MaxDoc()];
-				if (retArray.Length > 0)
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				try
 				{
-					TermDocs termDocs = reader.TermDocs();
-					TermEnum termEnum = reader.Terms(new Term(field, ""));
-					try
+					do 
 					{
-						if (termEnum.Term() == null)
+						Term term = termEnum.Term();
+						if (term == null || term.Field() != field)
+							break;
+						System.String termval = term.Text();
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
 						{
-							throw new System.SystemException("no terms in field " + field);
-						}
-						do 
-						{
-							Term term = termEnum.Term();
-							if (term.Field() != field)
-								break;
-							System.String termval = term.Text();
-							termDocs.Seek(termEnum);
-							while (termDocs.Next())
-							{
-								retArray[termDocs.Doc()] = termval;
-							}
+							retArray[termDocs.Doc()] = termval;
 						}
-						while (termEnum.Next());
-					}
-					finally
-					{
-						termDocs.Close();
-						termEnum.Close();
 					}
+					while (termEnum.Next());
+				}
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
 				}
-				Store(reader, field, SortField.STRING, retArray);
+				Store(reader, field, SortField.STRING, null, retArray);
 				return retArray;
 			}
 			return (System.String[]) ret;
@@ -332,74 +317,68 @@
 		public virtual StringIndex GetStringIndex(IndexReader reader, System.String field)
 		{
 			field = String.Intern(field);
-			System.Object ret = Lookup(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX);
+			System.Object ret = Lookup(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX, null);
 			if (ret == null)
 			{
 				int[] retArray = new int[reader.MaxDoc()];
 				System.String[] mterms = new System.String[reader.MaxDoc() + 1];
-				if (retArray.Length > 0)
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				int t = 0; // current term number
+				
+				// an entry for documents that have no terms in this field
+				// should a document with no terms be at top or bottom?
+				// this puts them at the top - if it is changed, FieldDocSortedHitQueue
+				// needs to change as well.
+				mterms[t++] = null;
+				
+				try
 				{
-					TermDocs termDocs = reader.TermDocs();
-					TermEnum termEnum = reader.Terms(new Term(field, ""));
-					int t = 0; // current term number
-					
-					// an entry for documents that have no terms in this field
-					// should a document with no terms be at top or bottom?
-					// this puts them at the top - if it is changed, FieldDocSortedHitQueue
-					// needs to change as well.
-					mterms[t++] = null;
-					
-					try
+					do 
 					{
-						if (termEnum.Term() == null)
+						Term term = termEnum.Term();
+						if (term == null || term.Field() != field)
+							break;
+						
+						// store term text
+						// we expect that there is at most one term per document
+						if (t >= mterms.Length)
+							throw new System.SystemException("there are more terms than " + "documents in field \"" + field + "\", but it's impossible to sort on " + "tokenized fields");
+						mterms[t] = term.Text();
+						
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
 						{
-							throw new System.SystemException("no terms in field " + field);
+							retArray[termDocs.Doc()] = t;
 						}
-						do 
-						{
-							Term term = termEnum.Term();
-							if (term.Field() != field)
-								break;
-							
-							// store term text
-							// we expect that there is at most one term per document
-							if (t >= mterms.Length)
-								throw new System.SystemException("there are more terms than " + "documents in field \"" + field + "\", but it's impossible to sort on " + "tokenized fields");
-							mterms[t] = term.Text();
-							
-							termDocs.Seek(termEnum);
-							while (termDocs.Next())
-							{
-								retArray[termDocs.Doc()] = t;
-							}
-							
-							t++;
-						}
-						while (termEnum.Next());
-					}
-					finally
-					{
-						termDocs.Close();
-						termEnum.Close();
-					}
-					
-					if (t == 0)
-					{
-						// if there are no terms, make the term array
-						// have a single null entry
-						mterms = new System.String[1];
-					}
-					else if (t < mterms.Length)
-					{
-						// if there are less terms than documents,
-						// trim off the dead array space
-						System.String[] terms = new System.String[t];
-						Array.Copy(mterms, 0, terms, 0, t);
-						mterms = terms;
+						
+						t++;
 					}
+					while (termEnum.Next());
 				}
-				StringIndex value_Renamed = new StringIndex(retArray, mterms);
-				Store(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX, value_Renamed);
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
+				}
+				
+				if (t == 0)
+				{
+					// if there are no terms, make the term array
+					// have a single null entry
+					mterms = new System.String[1];
+				}
+				else if (t < mterms.Length)
+				{
+					// if there are less terms than documents,
+					// trim off the dead array space
+					System.String[] terms = new System.String[t];
+					Array.Copy(mterms, 0, terms, 0, t);
+					mterms = terms;
+				}
+				
+                StringIndex value_Renamed = new StringIndex(retArray, mterms);
+				Store(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX, null, value_Renamed);
 				return value_Renamed;
 			}
 			return (StringIndex) ret;
@@ -420,7 +399,7 @@
 		public virtual System.Object GetAuto(IndexReader reader, System.String field)
 		{
 			field = String.Intern(field);
-			System.Object ret = Lookup(reader, field, SortField.AUTO);
+			System.Object ret = Lookup(reader, field, SortField.AUTO, null);
 			if (ret == null)
 			{
 				TermEnum enumerator = reader.Terms(new Term(field, ""));
@@ -435,18 +414,15 @@
 					{
 						System.String termtext = term.Text().Trim();
 						
-						/**
-						* Java 1.4 level code:
-						
-						if (pIntegers.matcher(termtext).matches())
-						return IntegerSortedHitQueue.comparator (reader, enumerator, field);
+                        /// <summary> Java 1.4 level code:
+                        /// if (pIntegers.matcher(termtext).matches())
+                        /// return IntegerSortedHitQueue.comparator (reader, enumerator, field);
+                        /// else if (pFloats.matcher(termtext).matches())
+                        /// return FloatSortedHitQueue.comparator (reader, enumerator, field);
+                        /// </summary>
 						
-						else if (pFloats.matcher(termtext).matches())
-						return FloatSortedHitQueue.comparator (reader, enumerator, field);
-						*/
-						
-						// Java 1.3 level code:
-						try
+                        // Java 1.3 level code:
+                        try
 						{
 							System.Int32.Parse(termtext);
 							ret = GetInts(reader, field);
@@ -465,7 +441,7 @@
 						}
 						if (ret != null)
 						{
-							Store(reader, field, SortField.AUTO, ret);
+							Store(reader, field, SortField.AUTO, null, ret);
 						}
 					}
 					else
@@ -489,35 +465,28 @@
 			if (ret == null)
 			{
 				System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()];
-				if (retArray.Length > 0)
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				try
 				{
-					TermDocs termDocs = reader.TermDocs();
-					TermEnum termEnum = reader.Terms(new Term(field, ""));
-					try
+					do 
 					{
-						if (termEnum.Term() == null)
+						Term term = termEnum.Term();
+						if (term == null || term.Field() != field)
+							break;
+						System.IComparable termval = comparator.GetComparable(term.Text());
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
 						{
-							throw new System.SystemException("no terms in field " + field);
+							retArray[termDocs.Doc()] = termval;
 						}
-						do 
-						{
-							Term term = termEnum.Term();
-							if (term.Field() != field)
-								break;
-							System.IComparable termval = comparator.GetComparable(term.Text());
-							termDocs.Seek(termEnum);
-							while (termDocs.Next())
-							{
-								retArray[termDocs.Doc()] = termval;
-							}
-						}
-						while (termEnum.Next());
-					}
-					finally
-					{
-						termDocs.Close();
-						termEnum.Close();
 					}
+					while (termEnum.Next());
+				}
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
 				}
 				Store(reader, field, comparator, retArray);
 				return retArray;

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldSortedHitQueue.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/FieldSortedHitQueue.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldSortedHitQueue.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldSortedHitQueue.cs Thu Aug 17 06:49:26 2006
@@ -37,7 +37,7 @@
 	/// </seealso>
 	/// <seealso cref="FieldCache">
 	/// </seealso>
-	class FieldSortedHitQueue : PriorityQueue
+	public class FieldSortedHitQueue : PriorityQueue
 	{
 		private class AnonymousClassScoreDocComparator : ScoreDocComparator
 		{
@@ -177,7 +177,7 @@
 		/// <param name="size"> The number of hits to retain.  Must be greater than zero.
 		/// </param>
 		/// <throws>  IOException </throws>
-		internal FieldSortedHitQueue(IndexReader reader, SortField[] fields, int size)
+		public FieldSortedHitQueue(IndexReader reader, SortField[] fields, int size)
 		{
 			int n = fields.Length;
 			comparators = new ScoreDocComparator[n];
@@ -186,7 +186,15 @@
 			{
 				System.String fieldname = fields[i].GetField();
 				comparators[i] = GetCachedComparator(reader, fieldname, fields[i].GetType(), fields[i].GetLocale(), fields[i].GetFactory());
-				this.fields[i] = new SortField(fieldname, comparators[i].SortType(), fields[i].GetReverse());
+				
+				if (comparators[i].SortType() == SortField.STRING)
+				{
+					this.fields[i] = new SortField(fieldname, fields[i].GetLocale(), fields[i].GetReverse());
+				}
+				else
+				{
+					this.fields[i] = new SortField(fieldname, comparators[i].SortType(), fields[i].GetReverse());
+				}
 			}
 			Initialize(size);
 		}
@@ -286,9 +294,9 @@
 		internal static readonly System.Collections.IDictionary Comparators = new System.Collections.Hashtable();
 		
 		/// <summary>Returns a comparator if it is in the cache. </summary>
-		internal static ScoreDocComparator Lookup(IndexReader reader, System.String field, int type, System.Object factory)
+		internal static ScoreDocComparator Lookup(IndexReader reader, System.String field, int type, System.Globalization.CultureInfo locale, System.Object factory)
 		{
-			FieldCacheImpl.Entry entry = (factory != null) ? new FieldCacheImpl.Entry(field, factory) : new FieldCacheImpl.Entry(field, type);
+			FieldCacheImpl.Entry entry = (factory != null) ? new FieldCacheImpl.Entry(field, factory) : new FieldCacheImpl.Entry(field, type, locale);
 			lock (Comparators.SyncRoot)
 			{
 				System.Collections.Hashtable readerCache = (System.Collections.Hashtable) Comparators[reader];
@@ -299,9 +307,9 @@
 		}
 		
 		/// <summary>Stores a comparator into the cache. </summary>
-		internal static System.Object Store(IndexReader reader, System.String field, int type, System.Object factory, System.Object value_Renamed)
+		internal static System.Object Store(IndexReader reader, System.String field, int type, System.Globalization.CultureInfo locale, System.Object factory, System.Object value_Renamed)
 		{
-			FieldCacheImpl.Entry entry = (factory != null) ? new FieldCacheImpl.Entry(field, factory) : new FieldCacheImpl.Entry(field, type);
+			FieldCacheImpl.Entry entry = (factory != null) ? new FieldCacheImpl.Entry(field, factory) : new FieldCacheImpl.Entry(field, type, locale);
 			lock (Comparators.SyncRoot)
 			{
 				System.Collections.Hashtable readerCache = (System.Collections.Hashtable) Comparators[reader];
@@ -323,7 +331,7 @@
 				return Lucene.Net.Search.ScoreDocComparator_Fields.INDEXORDER;
 			if (type == SortField.SCORE)
 				return Lucene.Net.Search.ScoreDocComparator_Fields.RELEVANCE;
-			ScoreDocComparator comparator = Lookup(reader, fieldname, type, factory);
+			ScoreDocComparator comparator = Lookup(reader, fieldname, type, locale, factory);
 			if (comparator == null)
 			{
 				switch (type)
@@ -356,7 +364,7 @@
 						throw new System.SystemException("unknown field type: " + type);
 					
 				}
-				Store(reader, fieldname, type, factory, comparator);
+				Store(reader, fieldname, type, locale, factory, comparator);
 			}
 			return comparator;
 		}

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FilteredQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/FilteredQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FilteredQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FilteredQuery.cs Thu Aug 17 06:49:26 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation
+ * Copyright 2004,2006 The Apache Software Foundation
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
 	/// <seealso cref="CachingWrapperFilter">
 	/// </seealso>
 	[Serializable]
-	public class FilteredQuery:Query
+	public class FilteredQuery : Query
 	{
 		[Serializable]
 		private class AnonymousClassWeight : Weight
@@ -51,16 +51,16 @@
 			}
 			private class AnonymousClassScorer : Scorer
 			{
-				private void  InitBlock(Lucene.Net.Search.Scorer scorer, System.Collections.BitArray bitset, AnonymousClassWeight enclosingInstance)
+				private void  InitBlock(System.Collections.BitArray bitset, Lucene.Net.Search.Scorer scorer, AnonymousClassWeight enclosingInstance)
 				{
-					this.scorer = scorer;
 					this.bitset = bitset;
+					this.scorer = scorer;
 					this.enclosingInstance = enclosingInstance;
 				}
-				private Lucene.Net.Search.Scorer scorer;
-				private System.Collections.BitArray bitset;
-				private AnonymousClassWeight enclosingInstance;
-				public AnonymousClassWeight Enclosing_Instance
+                private System.Collections.BitArray bitset;
+                private Lucene.Net.Search.Scorer scorer;
+                private AnonymousClassWeight enclosingInstance;
+                public AnonymousClassWeight Enclosing_Instance
 				{
 					get
 					{
@@ -68,30 +68,57 @@
 					}
 					
 				}
-				internal AnonymousClassScorer(Lucene.Net.Search.Scorer scorer, System.Collections.BitArray bitset, AnonymousClassWeight enclosingInstance, Lucene.Net.Search.Similarity Param1):base(Param1)
+				internal AnonymousClassScorer(System.Collections.BitArray bitset, Lucene.Net.Search.Scorer scorer, AnonymousClassWeight enclosingInstance, Lucene.Net.Search.Similarity Param1) : base(Param1)
 				{
-					InitBlock(scorer, bitset, enclosingInstance);
+					InitBlock(bitset, scorer, enclosingInstance);
 				}
 				
-				// pass these methods through to the enclosed scorer
 				public override bool Next()
 				{
-					return scorer.Next();
-				}
+                    do 
+                    {
+                        if (!scorer.Next())
+                        {
+                            return false;
+                        }
+                    }
+                    while (!bitset.Get(scorer.Doc()));
+                    /* When skipTo() is allowed on scorer it should be used here
+                    * in combination with bitset.nextSetBit(...)
+                    * See the while loop in skipTo() below.
+                    */
+                    return true;
+                }
 				public override int Doc()
 				{
 					return scorer.Doc();
 				}
-				public override bool SkipTo(int i)
+				
+                public override bool SkipTo(int i)
 				{
-					return scorer.SkipTo(i);
+					if (!scorer.SkipTo(i))
+					{
+						return false;
+					}
+					while (!bitset.Get(scorer.Doc()))
+					{
+						int nextFiltered = SupportClass.Number.NextSetBit(bitset, scorer.Doc() + 1);
+						if (nextFiltered == - 1)
+						{
+							return false;
+						}
+						else if (!scorer.SkipTo(nextFiltered))
+						{
+							return false;
+						}
+					}
+					return true;
 				}
 				
-				// if the document has been filtered out, set score to 0.0
 				public override float Score()
 				{
-					return (bitset.Get(scorer.Doc()))?scorer.Score():0.0f;
-				}
+                    return scorer.Score();
+                }
 				
 				// add an explanation about whether the document was filtered
 				public override Explanation Explain(int i)
@@ -146,13 +173,12 @@
 				return Enclosing_Instance;
 			}
 			
-			// return a scorer that overrides the enclosed query's score if
-			// the given hit has been filtered out.
-			public virtual Scorer Scorer(IndexReader indexReader)
+            // return a filtering scorer
+            public virtual Scorer Scorer(IndexReader indexReader)
 			{
 				Scorer scorer = weight.Scorer(indexReader);
 				System.Collections.BitArray bitset = Enclosing_Instance.filter.Bits(indexReader);
-				return new AnonymousClassScorer(scorer, bitset, this, similarity);
+				return new AnonymousClassScorer(bitset, scorer, this, similarity);
 			}
 		}
 		
@@ -244,5 +270,14 @@
 		{
 			return query.GetHashCode() ^ filter.GetHashCode();
 		}
-	}
+
+        public override System.Object Clone()
+        {
+            // {{Aroush-2.0}} is this Clone() OK?
+            FilteredQuery clone = (FilteredQuery) base.Clone();
+            clone.filter = this.filter;
+            clone.query = this.query;
+            return clone;
+        }
+    }
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FilteredTermEnum.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/FilteredTermEnum.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FilteredTermEnum.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FilteredTermEnum.cs Thu Aug 17 06:49:26 2006
@@ -40,7 +40,7 @@
 		/// <summary>Equality measure on the term </summary>
 		public abstract float Difference();
 		
-		/// <summary>Indiciates the end of the enumeration has been reached </summary>
+		/// <summary>Indicates the end of the enumeration has been reached </summary>
 		public abstract bool EndEnum();
 		
 		protected internal virtual void  SetEnum(TermEnum actualEnum)

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/HitIterator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/HitIterator.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/HitIterator.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/HitIterator.cs Thu Aug 17 06:49:26 2006
@@ -76,9 +76,11 @@
 		{
 			return hits.Length();
 		}
-		//UPGRADE_TODO: The following method was automatically generated and it must be implemented in order to preserve the class logic. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1232'"
-		virtual public void  Reset()
+
+        virtual public void  Reset()
 		{
-		}
+            // {{Aroush-2.0}} what do we do here?!
+            throw new System.Exception("{{Aroush}} Reset() needs to be implemented");
+        }
 	}
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/IndexSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/IndexSearcher.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/IndexSearcher.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/IndexSearcher.cs Thu Aug 17 06:49:26 2006
@@ -36,84 +36,7 @@
 	{
 		private class AnonymousClassHitCollector : HitCollector
 		{
-			public AnonymousClassHitCollector(System.Collections.BitArray bits, int[] totalHits, Lucene.Net.Search.HitQueue hq, int nDocs, IndexSearcher enclosingInstance)
-			{
-				InitBlock(bits, totalHits, hq, nDocs, enclosingInstance);
-			}
-			private void  InitBlock(System.Collections.BitArray bits, int[] totalHits, Lucene.Net.Search.HitQueue hq, int nDocs, IndexSearcher enclosingInstance)
-			{
-				this.bits = bits;
-				this.totalHits = totalHits;
-				this.hq = hq;
-				this.nDocs = nDocs;
-				this.enclosingInstance = enclosingInstance;
-			}
-			private System.Collections.BitArray bits;
-			private int[] totalHits;
-			private Lucene.Net.Search.HitQueue hq;
-			private int nDocs;
-			private IndexSearcher enclosingInstance;
-			public IndexSearcher Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			private float minScore = 0.0f;
-			public override void  Collect(int doc, float score)
-			{
-				if (score > 0.0f && (bits == null || bits.Get(doc)))
-				{
-					// skip docs not in bits
-					totalHits[0]++;
-					if (hq.Size() < nDocs || score >= minScore)
-					{
-						hq.Insert(new ScoreDoc(doc, score));
-						minScore = ((ScoreDoc) hq.Top()).score; // maintain minScore
-					}
-				}
-			}
-		}
-		private class AnonymousClassHitCollector1 : HitCollector
-		{
-			public AnonymousClassHitCollector1(System.Collections.BitArray bits, int[] totalHits, Lucene.Net.Search.FieldSortedHitQueue hq, IndexSearcher enclosingInstance)
-			{
-				InitBlock(bits, totalHits, hq, enclosingInstance);
-			}
-			private void  InitBlock(System.Collections.BitArray bits, int[] totalHits, Lucene.Net.Search.FieldSortedHitQueue hq, IndexSearcher enclosingInstance)
-			{
-				this.bits = bits;
-				this.totalHits = totalHits;
-				this.hq = hq;
-				this.enclosingInstance = enclosingInstance;
-			}
-			private System.Collections.BitArray bits;
-			private int[] totalHits;
-			private Lucene.Net.Search.FieldSortedHitQueue hq;
-			private IndexSearcher enclosingInstance;
-			public IndexSearcher Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			public override void  Collect(int doc, float score)
-			{
-				if (score > 0.0f && (bits == null || bits.Get(doc)))
-				{
-					// skip docs not in bits
-					totalHits[0]++;
-					hq.Insert(new FieldDoc(doc, score));
-				}
-			}
-		}
-		private class AnonymousClassHitCollector2 : HitCollector
-		{
-			public AnonymousClassHitCollector2(System.Collections.BitArray bits, Lucene.Net.Search.HitCollector results, IndexSearcher enclosingInstance)
+			public AnonymousClassHitCollector(System.Collections.BitArray bits, Lucene.Net.Search.HitCollector results, IndexSearcher enclosingInstance)
 			{
 				InitBlock(bits, results, enclosingInstance);
 			}
@@ -211,48 +134,23 @@
 		public override TopDocs Search(Weight weight, Filter filter, int nDocs)
 		{
 			
-			if (nDocs <= 0)
-			    // null might be returned from hq.top() below.
-				throw new System.ArgumentException("nDocs must be > 0");
-			
-			Scorer scorer = weight.Scorer(reader);
-			if (scorer == null)
-				return new TopDocs(0, new ScoreDoc[0], System.Single.NegativeInfinity);
-			
-			System.Collections.BitArray bits = filter != null?filter.Bits(reader):null;
-			HitQueue hq = new HitQueue(nDocs);
-			int[] totalHits = new int[1];
-			scorer.Score(new AnonymousClassHitCollector(bits, totalHits, hq, nDocs, this));
-			
-			ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
-			for (int i = hq.Size() - 1; i >= 0; i--)
-			    // put docs in array
-				scoreDocs[i] = (ScoreDoc) hq.Pop();
-			
-			float maxScore = (totalHits[0] == 0) ? System.Single.NegativeInfinity : scoreDocs[0].score;
-			
-			return new TopDocs(totalHits[0], scoreDocs, maxScore);
-		}
+            if (nDocs <= 0)
+                // null might be returned from hq.top() below.
+                throw new System.ArgumentException("nDocs must be > 0");
+			
+            TopDocCollector collector = new TopDocCollector(nDocs);
+            Search(weight, filter, collector);
+            return collector.TopDocs();
+        }
 		
 		// inherit javadoc
 		public override TopFieldDocs Search(Weight weight, Filter filter, int nDocs, Sort sort)
 		{
-			Scorer scorer = weight.Scorer(reader);
-			if (scorer == null)
-				return new TopFieldDocs(0, new ScoreDoc[0], sort.fields, System.Single.NegativeInfinity);
-			
-			System.Collections.BitArray bits = filter != null ? filter.Bits(reader) : null;
-			FieldSortedHitQueue hq = new FieldSortedHitQueue(reader, sort.fields, nDocs);
-			int[] totalHits = new int[1];
-			scorer.Score(new AnonymousClassHitCollector1(bits, totalHits, hq, this));
 			
-			ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
-			for (int i = hq.Size() - 1; i >= 0; i--)
-			// put docs in array
-				scoreDocs[i] = hq.FillFields((FieldDoc) hq.Pop());
-			
-			return new TopFieldDocs(totalHits[0], scoreDocs, hq.GetFields(), hq.GetMaxScore());
-		}
+            TopFieldDocCollector collector = new TopFieldDocCollector(reader, sort, nDocs);
+            Search(weight, filter, collector);
+            return (TopFieldDocs) collector.TopDocs();
+        }
 		
 		// inherit javadoc
 		public override void  Search(Weight weight, Filter filter, HitCollector results)
@@ -261,7 +159,7 @@
 			if (filter != null)
 			{
 				System.Collections.BitArray bits = filter.Bits(reader);
-				collector = new AnonymousClassHitCollector2(bits, results, this);
+				collector = new AnonymousClassHitCollector(bits, results, this);
 			}
 			
 			Scorer scorer = weight.Scorer(reader);

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MatchAllDocsQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/MatchAllDocsQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MatchAllDocsQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MatchAllDocsQuery.cs Thu Aug 17 06:49:26 2006
@@ -51,36 +51,35 @@
 			}
 			
 			internal IndexReader reader;
-			internal int count;
-			internal int maxDoc;
+            internal int id;
+			internal int maxId;
+			internal float score_Renamed_Field;
+			
+			internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w) : base(similarity)
+			{
+                InitBlock(enclosingInstance);
+                this.reader = reader;
+                id = - 1;
+                maxId = reader.MaxDoc() - 1;
+                score_Renamed_Field = w.GetValue();
+            }
 			
-			internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity) : base(similarity)
+			public override Explanation Explain(int doc)
 			{
-				InitBlock(enclosingInstance);
-				this.reader = reader;
-				count = - 1;
-				maxDoc = reader.MaxDoc();
+				return null; // not called... see MatchAllDocsWeight.explain()
 			}
 			
 			public override int Doc()
 			{
-				return count;
-			}
-			
-			public override Explanation Explain(int doc)
-			{
-				Explanation explanation = new Explanation();
-				explanation.SetValue(1.0f);
-				explanation.SetDescription("MatchAllDocsQuery");
-				return explanation;
+				return id;
 			}
 			
 			public override bool Next()
 			{
-				while (count < (maxDoc - 1))
+				while (id < maxId)
 				{
-					count++;
-					if (!reader.IsDeleted(count))
+					id++;
+					if (!reader.IsDeleted(id))
 					{
 						return true;
 					}
@@ -90,13 +89,13 @@
 			
 			public override float Score()
 			{
-				return 1.0f;
+				return score_Renamed_Field;
 			}
 			
 			public override bool SkipTo(int target)
 			{
-				count = target - 1;
-				return Next();
+                id = target - 1;
+                return Next();
 			}
 		}
 		
@@ -117,6 +116,8 @@
 				
 			}
 			private Searcher searcher;
+            private float queryWeight;
+            private float queryNorm;
 			
 			public MatchAllDocsWeight(MatchAllDocsQuery enclosingInstance, Searcher searcher)
 			{
@@ -136,33 +137,37 @@
 			
 			public virtual float GetValue()
 			{
-				return 1.0f;
+				return queryWeight;
 			}
 			
 			public virtual float SumOfSquaredWeights()
 			{
-				return 1.0f;
-			}
+                queryWeight = Enclosing_Instance.GetBoost();
+                return queryWeight * queryWeight;
+            }
 			
 			public virtual void  Normalize(float queryNorm)
 			{
-			}
+                this.queryNorm = queryNorm;
+                queryWeight *= this.queryNorm;
+            }
 			
 			public virtual Scorer Scorer(IndexReader reader)
 			{
-				return new MatchAllScorer(enclosingInstance, reader, Enclosing_Instance.GetSimilarity(searcher));
+				return new MatchAllScorer(enclosingInstance, reader, Enclosing_Instance.GetSimilarity(searcher), this);
 			}
 			
 			public virtual Explanation Explain(IndexReader reader, int doc)
 			{
 				// explain query weight
 				Explanation queryExpl = new Explanation();
-				queryExpl.SetDescription("MatchAllDocsQuery:");
-				
-				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
-				if (Enclosing_Instance.GetBoost() != 1.0f)
-					queryExpl.AddDetail(boostExpl);
-				queryExpl.SetValue(boostExpl.GetValue());
+				queryExpl.SetDescription("MatchAllDocsQuery, product of:");
+                queryExpl.SetValue(GetValue());
+                if (Enclosing_Instance.GetBoost() != 1.0f)
+                {
+                    queryExpl.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
+                }
+                queryExpl.AddDetail(new Explanation(queryNorm, "queryNorm"));
 				
 				return queryExpl;
 			}
@@ -173,7 +178,11 @@
 			return new MatchAllDocsWeight(this, searcher);
 		}
 		
-		public override System.String ToString(System.String field)
+        public override void  ExtractTerms(System.Collections.Hashtable terms)
+        {
+        }
+		
+        public override System.String ToString(System.String field)
 		{
 			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
 			buffer.Append("MatchAllDocsQuery");

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiPhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/MultiPhraseQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiPhraseQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiPhraseQuery.cs Thu Aug 17 06:49:26 2006
@@ -110,7 +110,15 @@
 			positions.Add((System.Int32) position);
 		}
 		
-		/// <summary> Returns the relative positions of terms in this phrase.</summary>
+        /// <summary> Returns a List<Term[]> of the terms in the multiphrase.
+        /// Do not modify the List or its contents.
+        /// </summary>
+        public virtual System.Collections.IList GetTermArrays()
+        {
+            return (System.Collections.IList) System.Collections.ArrayList.ReadOnly(new System.Collections.ArrayList(termArrays));
+        }
+
+        /// <summary> Returns the relative positions of terms in this phrase.</summary>
 		public virtual int[] GetPositions()
 		{
 			int[] result = new int[positions.Count];
@@ -119,7 +127,22 @@
 			return result;
 		}
 		
-		[Serializable]
+        // inherit javadoc
+        public override void  ExtractTerms(System.Collections.Hashtable terms)
+        {
+            for (System.Collections.IEnumerator iter = termArrays.GetEnumerator(); iter.MoveNext(); )
+            {
+                Term[] arr = (Term[]) iter.Current;
+                for (int i = 0; i < arr.Length; i++)
+                {
+                    Term tmp = arr[i];
+                    terms.Add(tmp, tmp);
+                }
+            }
+        }
+		
+		
+        [Serializable]
 		private class MultiPhraseWeight : Weight
 		{
 			private void  InitBlock(MultiPhraseQuery enclosingInstance)
@@ -337,7 +360,43 @@
 			
 			return buffer.ToString();
 		}
-
+		
+		
+        /// <summary>Returns true if <code>o</code> is equal to this. </summary>
+        public  override bool Equals(System.Object o)
+        {
+            if (!(o is MultiPhraseQuery))
+                return false;
+            MultiPhraseQuery other = (MultiPhraseQuery) o;
+            if (this.GetBoost() == other.GetBoost() && this.slop == other.slop)
+            {
+                System.Collections.IEnumerator iter1 = this.termArrays.GetEnumerator();
+                System.Collections.IEnumerator iter2 = other.termArrays.GetEnumerator();
+                while (iter1.MoveNext() && iter2.MoveNext())
+                {
+                    Term item1 = (Term) iter1.Current;
+                    Term item2 = (Term) iter2.Current;
+                    if (!item1.Equals(item2))
+                        return false;
+                }
+                iter1 = this.positions.GetEnumerator();
+                iter2 = other.positions.GetEnumerator();
+                while (iter1.MoveNext() && iter2.MoveNext())
+                {
+                    System.Int32 item1 = (System.Int32) iter1.Current;
+                    System.Int32 item2 = (System.Int32) iter2.Current;
+                    if (!item1.Equals(item2))
+                        return false;
+                }
+            }
+            return true;
+        }
+		
+        /// <summary>Returns a hash code value for this object.</summary>
+        public override int GetHashCode()
+        {
+            return BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0) ^ slop ^ termArrays.GetHashCode() ^ positions.GetHashCode() ^ 0x4AC65113;
+        }
         // {{Aroush-1.9}} Do we need this?!
         override public System.Object Clone()
 		{

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/MultiSearcher.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiSearcher.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiSearcher.cs Thu Aug 17 06:49:26 2006
@@ -193,15 +193,8 @@
 			return searchables[i].Doc(n - starts[i]); // dispatch to searcher
 		}
 		
-		/// <summary>Call {@link #subSearcher} instead.</summary>
-		/// <deprecated>
-		/// </deprecated>
-		public virtual int SearcherIndex(int n)
-		{
-			return SubSearcher(n);
-		}
 		
-		/// <summary>Returns index of the searcher for document <code>n</code> in the array
+        /// <summary>Returns index of the searcher for document <code>n</code> in the array
 		/// used to construct this searcher. 
 		/// </summary>
 		public virtual int SubSearcher(int n)

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiTermQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/MultiTermQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiTermQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiTermQuery.cs Thu Aug 17 06:49:26 2006
@@ -110,7 +110,7 @@
 		
 		public override int GetHashCode()
 		{
-			return term.GetHashCode();
+			return term.GetHashCode() + System.Convert.ToInt32(GetBoost());
 		}
 	}
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/PrefixQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/PrefixQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/PrefixQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/PrefixQuery.cs Thu Aug 17 06:49:26 2006
@@ -102,7 +102,7 @@
 		/// <summary>Returns a hash code value for this object.</summary>
 		public override int GetHashCode()
 		{
-			return BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0) ^ prefix.GetHashCode();
+			return BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0) ^ prefix.GetHashCode() ^ 0x6634D93C;
 		}
         // {{Aroush-1.9}} Do we need this?!
         override public System.Object Clone()

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Query.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Query.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Query.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Query.cs Thu Aug 17 06:49:26 2006
@@ -62,20 +62,21 @@
 			return boost;
 		}
 		
-		/// <summary>Prints a query to a string, with <code>field</code> as the default field
-		/// for terms.  <p>The representation used is one that is supposed to be readable
-		/// by {@link Lucene.Net.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>
-		/// </summary>
-		public abstract System.String ToString(System.String field);
+        /// <summary>Prints a query to a string, with <code>field</code> assumed to be the 
+        /// default field and omitted.
+        /// <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>
+        /// </summary>
+        public abstract System.String ToString(System.String field);
 		
 		/// <summary>Prints a query to a string. </summary>
 		public override System.String ToString()
@@ -147,7 +148,10 @@
 					for (int j = 0; j < clauses.Length; j++)
 					{
                         Query tmp = clauses[j].GetQuery();
-						uniques.Add(tmp, tmp);
+                        if (uniques.Contains(query) == false)
+                        {
+                            uniques.Add(tmp, tmp);
+                        }
 					}
 				}
 				else

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RangeFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/RangeFilter.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RangeFilter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RangeFilter.cs Thu Aug 17 06:49:26 2006
@@ -28,8 +28,8 @@
 	/// 
 	/// <p>
 	/// This code borrows heavily from {@link RangeQuery}, but is implemented as a Filter
-	/// (much like {@link DateFilter}).
-	/// </p>
+    /// 
+    /// </p>
 	/// </summary>
 	[Serializable]
 	public class RangeFilter : Filter

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/RangeQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RangeQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RangeQuery.cs Thu Aug 17 06:49:26 2006
@@ -185,8 +185,15 @@
 		/// <summary>Returns a hash code value for this object.</summary>
 		public override int GetHashCode()
 		{
-			return BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0) ^ (lowerTerm != null ? lowerTerm.GetHashCode():0) ^ (upperTerm != null?upperTerm.GetHashCode() : 0) ^ (this.inclusive ? 1 : 0);
-		}
+            int h = BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0);
+            h ^= (lowerTerm != null ? lowerTerm.GetHashCode() : 0);
+            // reversible mix to make lower and upper position dependent and
+            // to prevent them from cancelling out.
+            h ^= ((h << 25) | (h >> 8));
+            h ^= (upperTerm != null ? upperTerm.GetHashCode() : 0);
+            h ^= (this.inclusive ? 0x2742E74A : 0);
+            return h;
+        }
 		// {{Aroush-1.9}} Do we need this?!
 		override public System.Object Clone()
 		{

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_RegexQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Regex/_delete_RegexQuery.cs?rev=432239&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_RegexQuery.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_RegexQuery.cs Thu Aug 17 06:49:26 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using IndexReader = Lucene.Net.Index.IndexReader;
+using Term = Lucene.Net.Index.Term;
+using FilteredTermEnum = Lucene.Net.Search.FilteredTermEnum;
+using MultiTermQuery = Lucene.Net.Search.MultiTermQuery;
+
+namespace _delete_Lucene.Net.Search.Regex
+{
+#if DELETE_ME	
+	[Serializable]
+	public class RegexQuery : MultiTermQuery
+	{
+		public RegexQuery(Term term) : base(term)
+		{
+		}
+		
+		protected internal override FilteredTermEnum GetEnum(IndexReader reader)
+		{
+			Term term = new Term(GetTerm().Field(), GetTerm().Text());
+			return new RegexTermEnum(reader, term);
+		}
+		
+		public  override bool Equals(System.Object o)
+		{
+			if (o is RegexQuery)
+				return base.Equals(o);
+			
+			return false;
+		}
+		
+        public override int GetHashCode()
+		{
+			return base.GetHashCode();
+		}
+	}
+#endif
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_RegexTermEnum.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Regex/_delete_RegexTermEnum.cs?rev=432239&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_RegexTermEnum.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_RegexTermEnum.cs Thu Aug 17 06:49:26 2006
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using IndexReader = Lucene.Net.Index.IndexReader;
+using Term = Lucene.Net.Index.Term;
+using FilteredTermEnum = Lucene.Net.Search.FilteredTermEnum;
+using Pattern = System.Text.RegularExpressions.Regex;
+
+namespace _delete_Lucene.Net.Search.Regex
+{
+#if DELETE_ME	
+	public class RegexTermEnum : FilteredTermEnum
+	{
+		private System.String field = "";
+		private System.String pre = "";
+		internal bool endEnum = false;
+		private Pattern pattern;
+		
+		public RegexTermEnum(IndexReader reader, Term term) : base()
+		{
+			field = term.Field();
+			System.String text = term.Text();
+			
+			pattern = new Pattern(text);
+			
+			// Find the first regex character position, to find the
+			// maximum prefix to use for term enumeration
+			int index = 0;
+			while (index < text.Length)
+			{
+				char c = text[index];
+				
+				if (!System.Char.IsLetterOrDigit(c))
+					break;
+				
+				index++;
+			}
+			
+			pre = text.Substring(0, (index) - (0));
+			
+			SetEnum(reader.Terms(new Term(term.Field(), pre)));
+		}
+		
+		protected internal override bool TermCompare(Term term)
+		{
+			if ((System.Object) field == (System.Object) term.Field())
+			{
+				System.String searchText = term.Text();
+				if (searchText.StartsWith(pre))
+				{
+                    return pattern.Match(searchText).Success;
+				}
+			}
+			endEnum = true;
+			return false;
+		}
+		
+		public override float Difference()
+		{
+			// TODO: adjust difference based on distance of searchTerm.text() and term().text()
+			return 1.0f;
+		}
+		
+		public override bool EndEnum()
+		{
+			return endEnum;
+		}
+		
+		public override void  Close()
+		{
+			base.Close();
+			field = null;
+		}
+	}
+#endif
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_SpanRegexQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Regex/_delete_SpanRegexQuery.cs?rev=432239&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_SpanRegexQuery.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Regex/_delete_SpanRegexQuery.cs Thu Aug 17 06:49:26 2006
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using IndexReader = Lucene.Net.Index.IndexReader;
+using Term = Lucene.Net.Index.Term;
+using BooleanClause = Lucene.Net.Search.BooleanClause;
+using BooleanQuery = Lucene.Net.Search.BooleanQuery;
+using Query = Lucene.Net.Search.Query;
+using TermQuery = Lucene.Net.Search.TermQuery;
+using SpanOrQuery = Lucene.Net.Search.Spans.SpanOrQuery;
+using SpanQuery = Lucene.Net.Search.Spans.SpanQuery;
+using SpanTermQuery = Lucene.Net.Search.Spans.SpanTermQuery;
+using ToStringUtils = Lucene.Net.Util.ToStringUtils;
+
+namespace _delete_Lucene.Net.Search.Regex
+{
+#if DELETE_ME	
+	[Serializable]
+	public class SpanRegexQuery:SpanQuery
+	{
+		virtual public Term Term
+		{
+			get
+			{
+				return term;
+			}
+			
+		}
+		private Term term;
+		
+		public SpanRegexQuery(Term term)
+		{
+			this.term = term;
+		}
+		
+		public override Query Rewrite(IndexReader reader)
+		{
+			Query orig = new RegexQuery(term).Rewrite(reader);
+			
+			// RegexQuery (via MultiTermQuery).rewrite always returns a BooleanQuery
+			BooleanQuery bq = (BooleanQuery) orig;
+			
+			BooleanClause[] clauses = bq.GetClauses();
+			SpanQuery[] sqs = new SpanQuery[clauses.Length];
+			for (int i = 0; i < clauses.Length; i++)
+			{
+				BooleanClause clause = clauses[i];
+				
+				// Clauses from RegexQuery.rewrite are always TermQuery's
+				TermQuery tq = (TermQuery) clause.GetQuery();
+				
+				sqs[i] = new SpanTermQuery(tq.GetTerm());
+				sqs[i].SetBoost(tq.GetBoost());
+			}
+			
+			SpanOrQuery query = new SpanOrQuery(sqs);
+			query.SetBoost(orig.GetBoost());
+			
+			return query;
+		}
+		
+		public override Lucene.Net.Search.Spans.Spans GetSpans(IndexReader reader)
+		{
+			throw new System.NotSupportedException("Query should have been rewritten");
+		}
+		
+		public override System.String GetField()
+		{
+			return term.Field();
+		}
+		
+		public override System.Collections.ICollection GetTerms()
+		{
+			System.Collections.ArrayList terms = new System.Collections.ArrayList();
+            terms.Add(term);
+			return terms;
+		}
+		
+		public  override bool Equals(System.Object o)
+		{
+			if (this == o)
+				return true;
+			if (o == null || GetType() != o.GetType())
+				return false;
+			
+			SpanRegexQuery that = (SpanRegexQuery) o;
+			
+			return term.Equals(that.term) && GetBoost() == that.GetBoost();
+		}
+		
+		public override int GetHashCode()
+		{
+			return term.GetHashCode();
+		}
+		
+		public override System.String ToString(System.String field)
+		{
+			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
+			buffer.Append("spanRegexQuery(");
+			buffer.Append(term);
+			buffer.Append(")");
+			buffer.Append(ToStringUtils.Boost(GetBoost()));
+			return buffer.ToString();
+		}
+	}
+#endif
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RemoteSearchable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/RemoteSearchable.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RemoteSearchable.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RemoteSearchable.cs Thu Aug 17 06:49:26 2006
@@ -38,12 +38,6 @@
 			this.local = local;
 		}
 		
-		// this implementation should be removed when the deprecated
-		// Searchable#search(Query,Filter,HitCollector) is removed
-		public virtual void  Search(Query query, Filter filter, HitCollector results)
-		{
-			local.Search(query, filter, results);
-		}
 		
 		public virtual void  Search(Weight weight, Filter filter, HitCollector results)
 		{
@@ -71,24 +65,11 @@
 			return local.MaxDoc();
 		}
 		
-		// this implementation should be removed when the deprecated
-		// Searchable#search(Query,Filter,int) is removed
-		public virtual TopDocs Search(Query query, Filter filter, int n)
-		{
-			return local.Search(query, filter, n);
-		}
-		
 		public virtual TopDocs Search(Weight weight, Filter filter, int n)
 		{
 			return local.Search(weight, filter, n);
 		}
 		
-		// this implementation should be removed when the deprecated
-		// Searchable#search(Query,Filter,int,Sort) is removed
-		public virtual TopFieldDocs Search(Query query, Filter filter, int n, Sort sort)
-		{
-			return local.Search(query, filter, n, sort);
-		}
 		
 		public virtual TopFieldDocs Search(Weight weight, Filter filter, int n, Sort sort)
 		{
@@ -105,43 +86,10 @@
 			return local.Rewrite(original);
 		}
 		
-		// this implementation should be removed when the deprecated
-		// Searchable#explain(Query,int) is removed
-		public virtual Explanation Explain(Query query, int doc)
-		{
-			return local.Explain(query, doc);
-		}
-		
 		public virtual Explanation Explain(Weight weight, int doc)
 		{
 			return local.Explain(weight, doc);
 		}
-		
-        public override System.Object InitializeLifetimeService()
-        {
-            long initialLeaseTime, sponsorshipTimeout, renewOnCallTime;
-
-            initialLeaseTime = SupportClass.AppSettings.Get("Lucene.Net.Remoting.Lifetime.initialLeaseTime", -1);
-            sponsorshipTimeout = SupportClass.AppSettings.Get("Lucene.Net.Remoting.Lifetime.sponsorshipTimeout", -1);
-            renewOnCallTime = SupportClass.AppSettings.Get("Lucene.Net.Remoting.Lifetime.renewOnCallTime", -1);
-
-            if ((initialLeaseTime == -1) || (sponsorshipTimeout == -1) || (renewOnCallTime == -1))
-            {
-                return null;
-            }
-            else
-            {
-                System.Runtime.Remoting.Lifetime.ILease lease = 
-                    (System.Runtime.Remoting.Lifetime.ILease) base.InitializeLifetimeService();
-                if (lease.CurrentState == System.Runtime.Remoting.Lifetime.LeaseState.Initial)
-                {
-                    lease.InitialLeaseTime = System.TimeSpan.FromMinutes(initialLeaseTime);
-                    lease.SponsorshipTimeout = System.TimeSpan.FromMinutes(sponsorshipTimeout);
-                    lease.RenewOnCallTime = System.TimeSpan.FromSeconds(renewOnCallTime);
-                }
-                return lease;
-            }
-        }
 
 		/// <summary>Exports a searcher for the index in args[0] named
 		/// "//localhost/Searchable". 

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searchable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Searchable.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searchable.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searchable.cs Thu Aug 17 06:49:26 2006
@@ -47,25 +47,16 @@
         /// non-high-scoring hits.
         /// 
         /// </summary>
-        /// <param name="query">to match documents
+        /// <param name="weight">to match documents
         /// </param>
         /// <param name="filter">if non-null, a bitset used to eliminate some documents
         /// </param>
         /// <param name="results">to receive hits
         /// </param>
         /// <throws>  BooleanQuery.TooManyClauses </throws>
-        /// <summary> 
-        /// </summary>
-        /// <deprecated>
-        /// </deprecated>
-        void  Search(Query query, Filter filter, HitCollector results);
-
-        /// <summary>Expert: Low-level search implementation.
-        /// Identical to {@link #Search(Query, Filter, HitCollector)}, but takes
-        /// a Weight instead of a query.
-        /// </summary>
         void  Search(Weight weight, Filter filter, HitCollector results);
 
+
         /// <summary>Frees resources associated with this Searcher.
         /// Be careful not to call this method while you are still using objects
         /// like {@link Hits}.
@@ -101,16 +92,6 @@
         /// {@link Searcher#Search(Query,Filter)} instead.
         /// </summary>
         /// <throws>  BooleanQuery.TooManyClauses </throws>
-        /// <summary> 
-        /// </summary>
-        /// <deprecated>
-        /// </deprecated>
-        TopDocs Search(Query query, Filter filter, int n);
-		
-        /// <summary>Expert: Low-level search implementation.
-        /// Identical to {@link #Search(Query, Filter, int)}, but takes
-        /// a Weight instead of a query.
-        /// </summary>
         TopDocs Search(Weight weight, Filter filter, int n);
 		
         /// <summary>Expert: Returns the stored fields of document <code>i</code>.
@@ -124,20 +105,17 @@
         /// <throws>  BooleanQuery.TooManyClauses </throws>
         Query Rewrite(Query query);
 		
-        /// <summary>Returns an Explanation that describes how <code>doc</code> scored against
-        /// <code>query</code>.
+        /// <summary>Expert: low-level implementation method
+        /// Returns an Explanation that describes how <code>doc</code> scored against
+        /// <code>weight</code>.
         /// 
         /// <p>This is intended to be used in developing Similarity implementations,
         /// and, for good performance, should not be displayed with every hit.
         /// Computing an explanation is as expensive as executing the query over the
         /// entire index.
+        /// <p>Applications should call {@link Searcher#Explain(Query, int)}.
         /// </summary>
         /// <throws>  BooleanQuery.TooManyClauses </throws>
-        Explanation Explain(Query query, int doc);
-		
-        /// <summary> Identical to {@link #Search(Query, Filter, HitCollector)}, but takes
-        /// a Weight instead of a query.
-        /// </summary>
         Explanation Explain(Weight weight, int doc);
 		
         /// <summary>Expert: Low-level search implementation with arbitrary sorting.  Finds
@@ -146,19 +124,9 @@
         /// <code>sort</code>.
         /// 
         /// <p>Applications should usually call {@link
-        /// Searcher#Search(Query,Filter,Sort)} instead.
+        /// Searcher#search(Query,Filter,Sort)} instead.
         /// </summary>
         /// <throws>  BooleanQuery.TooManyClauses </throws>
-        /// <summary> 
-        /// </summary>
-        /// <deprecated>
-        /// </deprecated>
-        TopFieldDocs Search(Query query, Filter filter, int n, Sort sort);
-		
-        /// <summary>Expert: Low-level search implementation.
-        /// Identical to {@link #Search(Query, Filter, int, Sort)}, but takes
-        /// a Weight instead of a query.
-        /// </summary>
         TopFieldDocs Search(Weight weight, Filter filter, int n, Sort sort);
     }
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanFirstQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Spans/SpanFirstQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanFirstQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanFirstQuery.cs Thu Aug 17 06:49:26 2006
@@ -120,7 +120,12 @@
 			return match.GetField();
 		}
 		
-		public override System.Collections.ICollection GetTerms()
+        /// <summary>Returns a collection of all terms matched by this query.</summary>
+        /// <deprecated> use ExtractTerms instead
+        /// </deprecated>
+        /// <seealso cref="#ExtractTerms(Set)">
+        /// </seealso>
+        public override System.Collections.ICollection GetTerms()
 		{
 			return match.GetTerms();
 		}
@@ -137,7 +142,12 @@
 			return buffer.ToString();
 		}
 		
-		public override Spans GetSpans(IndexReader reader)
+        public override void  ExtractTerms(System.Collections.Hashtable terms)
+        {
+            match.ExtractTerms(terms);
+        }
+		
+        public override Spans GetSpans(IndexReader reader)
 		{
 			return new AnonymousClassSpans(reader, this);
 		}
@@ -162,5 +172,24 @@
 				return this; // no clauses rewrote
 			}
 		}
-	}
+		
+        public  override bool Equals(System.Object o)
+        {
+            if (this == o)
+                return true;
+            if (!(o is SpanFirstQuery))
+                return false;
+			
+            SpanFirstQuery other = (SpanFirstQuery) o;
+            return this.end == other.end && this.match.Equals(other.match) && this.GetBoost() == other.GetBoost();
+        }
+		
+        public override int GetHashCode()
+        {
+            int h = match.GetHashCode();
+            h ^= ((h << 8) | ((int) (((uint) h) >> 25))); // reversible
+            h ^= System.Convert.ToInt32(GetBoost()) ^ end;
+            return h;
+        }
+    }
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanNearQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Spans/SpanNearQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanNearQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanNearQuery.cs Thu Aug 17 06:49:26 2006
@@ -87,7 +87,12 @@
 			return field;
 		}
 		
-		public override System.Collections.ICollection GetTerms()
+        /// <summary>Returns a collection of all terms matched by this query.</summary>
+        /// <deprecated> use extractTerms instead
+        /// </deprecated>
+        /// <seealso cref="#extractTerms(Set)">
+        /// </seealso>
+        public override System.Collections.ICollection GetTerms()
 		{
 			System.Collections.ArrayList terms = new System.Collections.ArrayList();
 			System.Collections.IEnumerator i = clauses.GetEnumerator();
@@ -99,7 +104,18 @@
 			return terms;
 		}
 		
-		public override System.String ToString(System.String field)
+        public override void  ExtractTerms(System.Collections.Hashtable terms)
+        {
+            System.Collections.IEnumerator i = clauses.GetEnumerator();
+            while (i.MoveNext())
+            {
+                SpanQuery clause = (SpanQuery) i.Current;
+                clause.ExtractTerms(terms);
+            }
+        }
+		
+		
+        public override System.String ToString(System.String field)
 		{
 			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
 			buffer.Append("spanNear([");
@@ -165,7 +181,7 @@
 		{
 			if (this == o)
 				return true;
-			if (o == null || GetType() != o.GetType())
+			if (!(o is SpanNearQuery))
 				return false;
 			
 			SpanNearQuery spanNearQuery = (SpanNearQuery) o;
@@ -174,22 +190,34 @@
 				return false;
 			if (slop != spanNearQuery.slop)
 				return false;
-			if (!clauses.Equals(spanNearQuery.clauses))
-				return false;
-			if (!field.Equals(spanNearQuery.field))
-				return false;
+
+            if (clauses.Count != spanNearQuery.clauses.Count)
+                return false;
+            System.Collections.IEnumerator iter1 = clauses.GetEnumerator();
+            System.Collections.IEnumerator iter2 = spanNearQuery.clauses.GetEnumerator();
+            while (iter1.MoveNext() && iter2.MoveNext())
+            {
+                SpanQuery item1 = (SpanQuery) iter1.Current;
+                SpanQuery item2 = (SpanQuery) iter2.Current;
+                if (!item1.Equals(item2))
+                    return false;
+            }
 			
 			return GetBoost() == spanNearQuery.GetBoost();
 		}
 		
 		public override int GetHashCode()
 		{
-			int result;
-			result = clauses.GetHashCode();
-			result += slop * 29;
-			result += (inOrder?1:0);
-			result ^= field.GetHashCode();
-			return result;
+            long result;
+            result = clauses.GetHashCode();
+            // Mix bits before folding in things like boost, since it could cancel the
+            // last element of clauses.  This particular mix also serves to
+            // differentiate SpanNearQuery hashcodes from others.
+            result ^= ((result << 14) | (result >> 19)); // reversible
+            result += System.Convert.ToInt32(GetBoost());
+            result += slop;
+            result ^= (inOrder ? (long) 0x99AFD3BD : 0);
+            return (int) result;
 		}
 	}
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanNotQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Spans/SpanNotQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanNotQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanNotQuery.cs Thu Aug 17 06:49:26 2006
@@ -38,6 +38,7 @@
 				this.enclosingInstance = enclosingInstance;
 				includeSpans = Enclosing_Instance.include.GetSpans(reader);
 				excludeSpans = Enclosing_Instance.exclude.GetSpans(reader);
+                moreExclude = excludeSpans.Next();
 			}
 			private Lucene.Net.Index.IndexReader reader;
 			private SpanNotQuery enclosingInstance;
@@ -53,7 +54,7 @@
 			private bool moreInclude = true;
 			
 			private Spans excludeSpans;
-			private bool moreExclude = true;
+			private bool moreExclude;
 			
 			public virtual bool Next()
 			{
@@ -154,10 +155,20 @@
 			return include.GetField();
 		}
 		
-		public override System.Collections.ICollection GetTerms()
+        /// <summary>Returns a collection of all terms matched by this query.</summary>
+        /// <deprecated> use extractTerms instead
+        /// </deprecated>
+        /// <seealso cref="#ExtractTerms(Set)">
+        /// </seealso>
+        public override System.Collections.ICollection GetTerms()
 		{
 			return include.GetTerms();
 		}
+
+        public override void  ExtractTerms(System.Collections.Hashtable terms)
+        {
+            include.ExtractTerms(terms);
+        }
 		
 		public override System.String ToString(System.String field)
 		{
@@ -204,5 +215,27 @@
 				return this; // no clauses rewrote
 			}
 		}
-	}
+		
+        /// <summary>Returns true iff <code>o</code> is equal to this. </summary>
+        public  override bool Equals(System.Object o)
+        {
+            if (this == o)
+                return true;
+            if (!(o is SpanNotQuery))
+                return false;
+			
+            SpanNotQuery other = (SpanNotQuery) o;
+            return this.include.Equals(other.include) && this.exclude.Equals(other.exclude) && this.GetBoost() == other.GetBoost();
+        }
+		
+        public override int GetHashCode()
+        {
+            int h = include.GetHashCode();
+            h = (h << 1) | ((int) (((uint) h) >> 31)); // rotate left
+            h ^= exclude.GetHashCode();
+            h = (h << 1) | ((int) (((uint) h) >> 31)); // rotate left
+            h ^= System.Convert.ToInt32(GetBoost());
+            return h;
+        }
+    }
 }

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanOrQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Spans/SpanOrQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanOrQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanOrQuery.cs Thu Aug 17 06:49:26 2006
@@ -197,7 +197,12 @@
 			return field;
 		}
 		
-		public override System.Collections.ICollection GetTerms()
+        /// <summary>Returns a collection of all terms matched by this query.</summary>
+        /// <deprecated> use ExtractTerms instead
+        /// </deprecated>
+        /// <seealso cref="#ExtractTerms(Set)">
+        /// </seealso>
+        public override System.Collections.ICollection GetTerms()
 		{
 			System.Collections.ArrayList terms = new System.Collections.ArrayList();
 			System.Collections.IEnumerator i = clauses.GetEnumerator();
@@ -208,8 +213,19 @@
 			}
 			return terms;
 		}
+
+        public override void  ExtractTerms(System.Collections.Hashtable terms)
+        {
+            System.Collections.IEnumerator i = clauses.GetEnumerator();
+            while (i.MoveNext())
+            {
+                SpanQuery clause = (SpanQuery) i.Current;
+                clause.ExtractTerms(terms);
+            }
+        }
 		
-		public override Query Rewrite(IndexReader reader)
+		
+        public override Query Rewrite(IndexReader reader)
 		{
 			SpanOrQuery clone = null;
 			for (int i = 0; i < clauses.Count; i++)
@@ -272,10 +288,10 @@
 		
 		public override int GetHashCode()
 		{
-			int result;
-			result = clauses.GetHashCode();
-			result = 29 * result + field.GetHashCode();
-			return result;
+            int h = clauses.GetHashCode();
+            h ^= ((h << 10) | (h >> 23));
+            h ^= System.Convert.ToInt32(GetBoost());
+            return h;
 		}
 		
 		private class SpanQueue : PriorityQueue

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Spans/SpanQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanQuery.cs Thu Aug 17 06:49:26 2006
@@ -35,8 +35,12 @@
 		/// <summary>Returns the name of the field matched by this query.</summary>
 		public abstract System.String GetField();
 		
-		/// <summary>Returns a collection of all terms matched by this query.</summary>
-		public abstract System.Collections.ICollection GetTerms();
+        /// <summary>Returns a collection of all terms matched by this query.</summary>
+        /// <deprecated> use extractTerms instead
+        /// </deprecated>
+        /// <seealso cref="Query#extractTerms(Set)">
+        /// </seealso>
+        public abstract System.Collections.ICollection GetTerms();
 		
 		protected internal override Weight CreateWeight(Searcher searcher)
 		{

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Spans/SpanScorer.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanScorer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanScorer.cs Thu Aug 17 06:49:26 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation
+ * Copyright 2006 The Apache Software Foundation
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,8 @@
 			this.norms = norms;
 			this.weight = weight;
 			this.value_Renamed = weight.GetValue();
-		}
+            doc = - 1;
+        }
 		
 		public override bool Next()
 		{
@@ -52,52 +53,55 @@
 				more = spans.Next();
 				firstTime = false;
 			}
-			
-			if (!more)
-				return false;
-			
-			freq = 0.0f;
-			doc = spans.Doc();
-			
-			while (more && doc == spans.Doc())
-			{
-				int matchLength = spans.End() - spans.Start();
-				freq += GetSimilarity().SloppyFreq(matchLength);
-				more = spans.Next();
-			}
-			
-			return more || freq != 0.0f;
-		}
-		
-		public override int Doc()
-		{
-			return doc;
-		}
-		
-		public override float Score()
-		{
-			float raw = GetSimilarity().Tf(freq) * value_Renamed; // raw score
-			return raw * Similarity.DecodeNorm(norms[doc]); // normalize
-		}
+            return SetFreqCurrentDoc();
+        }
 		
 		public override bool SkipTo(int target)
 		{
-			more = spans.SkipTo(target);
-			
-			if (!more)
-				return false;
-			
-			freq = 0.0f;
-			doc = spans.Doc();
-			
-			while (more && spans.Doc() == target)
-			{
-				freq += GetSimilarity().SloppyFreq(spans.End() - spans.Start());
-				more = spans.Next();
-			}
-			
-			return more || freq != 0.0f;
-		}
+            if (firstTime)
+            {
+                more = spans.SkipTo(target);
+                firstTime = false;
+            }
+            if (!more)
+            {
+                return false;
+            }
+            if (spans.Doc() < target)
+            {
+                // setFreqCurrentDoc() leaves spans.doc() ahead
+                more = spans.SkipTo(target);
+            }
+            return SetFreqCurrentDoc();
+        }
+		
+        private bool SetFreqCurrentDoc()
+        {
+            if (!more)
+            {
+                return false;
+            }
+            doc = spans.Doc();
+            freq = 0.0f;
+            while (more && doc == spans.Doc())
+            {
+                int matchLength = spans.End() - spans.Start();
+                freq += GetSimilarity().SloppyFreq(matchLength);
+                more = spans.Next();
+            }
+            return more || (freq != 0);
+        }
+		
+        public override int Doc()
+        {
+            return doc;
+        }
+		
+        public override float Score()
+        {
+            float raw = GetSimilarity().Tf(freq) * value_Renamed; // raw score
+            return raw * Similarity.DecodeNorm(norms[doc]); // normalize
+        }
 		
 		public override Explanation Explain(int doc)
 		{
@@ -105,7 +109,7 @@
 			
 			SkipTo(doc);
 			
-			float phraseFreq = (Doc() == doc)?freq:0.0f;
+			float phraseFreq = (Doc() == doc) ? freq : 0.0f;
 			tfExplanation.SetValue(GetSimilarity().Tf(phraseFreq));
 			tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");
 			

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanTermQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Spans/SpanTermQuery.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanTermQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanTermQuery.cs Thu Aug 17 06:49:26 2006
@@ -113,7 +113,7 @@
 			
 			public override System.String ToString()
 			{
-				return "spans(" + Enclosing_Instance.ToString() + ")@" + (doc == - 1?"START":((doc == System.Int32.MaxValue)?"END":doc + "-" + position));
+				return "spans(" + Enclosing_Instance.ToString() + ")@" + (doc == - 1 ? "START" : ((doc == System.Int32.MaxValue) ? "END" : doc + "-" + position));
 			}
 		}
 		private Term term;
@@ -135,12 +135,22 @@
 			return term.Field();
 		}
 		
-		public override System.Collections.ICollection GetTerms()
+        /// <summary>Returns a collection of all terms matched by this query.</summary>
+        /// <deprecated> use extractTerms instead
+        /// </deprecated>
+        /// <seealso cref="#extractTerms(Set)">
+        /// </seealso>
+        public override System.Collections.ICollection GetTerms()
 		{
 			System.Collections.ArrayList terms = new System.Collections.ArrayList();
 			terms.Add(term);
 			return terms;
 		}
+
+        public override void  ExtractTerms(System.Collections.Hashtable terms)
+        {
+            terms.Add(term, term);
+        }
 		
 		public override System.String ToString(System.String field)
 		{
@@ -167,7 +177,7 @@
 		/// <summary>Returns a hash code value for this object.</summary>
 		public override int GetHashCode()
 		{
-            return GetBoost().ToString().GetHashCode() ^ term.GetHashCode();    // {{Aroush-1.9}} Is this OK?
+            return GetBoost().ToString().GetHashCode() ^ term.GetHashCode() ^ unchecked((int) 0xD23FE494);    // {{Aroush-1.9}} Is this OK?
 		}
 		
 		public override Spans GetSpans(IndexReader reader)

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanWeight.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Spans/SpanWeight.cs?rev=432239&r1=432238&r2=432239&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanWeight.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanWeight.cs Thu Aug 17 06:49:26 2006
@@ -36,14 +36,15 @@
 		private float queryNorm;
 		private float queryWeight;
 		
-		private System.Collections.ICollection terms;
+		private System.Collections.Hashtable terms;
 		private SpanQuery query;
 		
 		public SpanWeight(SpanQuery query, Searcher searcher)
 		{
 			this.similarity = query.GetSimilarity(searcher);
 			this.query = query;
-			this.terms = query.GetTerms();
+            terms = new System.Collections.Hashtable();
+            query.ExtractTerms(terms);
 			
 			idf = this.query.GetSimilarity(searcher).Idf(terms, searcher);
 		}