lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dougs...@apache.org
Subject svn commit: r798995 [33/35] - in /incubator/lucene.net/trunk/C#/src: Lucene.Net/ Lucene.Net/Analysis/ Lucene.Net/Analysis/Standard/ Lucene.Net/Document/ Lucene.Net/Index/ Lucene.Net/QueryParser/ Lucene.Net/Search/ Lucene.Net/Search/Function/ Lucene.Net...
Date Wed, 29 Jul 2009 18:04:24 GMT
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestRangeFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestRangeFilter.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestRangeFilter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestRangeFilter.cs Wed Jul 29 18:04:12 2009
@@ -21,166 +21,364 @@
 
 using IndexReader = Lucene.Net.Index.IndexReader;
 using Term = Lucene.Net.Index.Term;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
 
 namespace Lucene.Net.Search
 {
-	
-	/// <summary> A basic 'positive' Unit test class for the RangeFilter class.
-	/// 
-	/// <p>
-	/// NOTE: at the moment, this class only tests for 'positive' results,
-	/// it does not verify the results to ensure there are no 'false positives',
-	/// nor does it adequately test 'negative' results.  It also does not test
-	/// that garbage in results in an Exception.
-	/// </summary>
-	[TestFixture]
-	public class TestRangeFilter : BaseTestRangeFilter
-	{
-		
-		[Test]
-		public virtual void  TestRangeFilterId()
-		{
-			
-			IndexReader reader = IndexReader.Open(index);
-			IndexSearcher search = new IndexSearcher(reader);
-			
-			int medId = ((maxId - minId) / 2);
-			
-			System.String minIP = Pad(minId);
-			System.String maxIP = Pad(maxId);
-			System.String medIP = Pad(medId);
-			
-			int numDocs = reader.NumDocs();
-			
-			Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs");
-			
-			Hits result;
-			Query q = new TermQuery(new Term("body", "body"));
-			
-			// test id, bounded on both ends
-			
-			result = search.Search(q, new RangeFilter("id", minIP, maxIP, T, T));
-			Assert.AreEqual(numDocs, result.Length(), "find all");
-			
-			result = search.Search(q, new RangeFilter("id", minIP, maxIP, T, F));
-			Assert.AreEqual(numDocs - 1, result.Length(), "all but last");
-			
-			result = search.Search(q, new RangeFilter("id", minIP, maxIP, F, T));
-			Assert.AreEqual(numDocs - 1, result.Length(), "all but first");
-			
-			result = search.Search(q, new RangeFilter("id", minIP, maxIP, F, F));
-			Assert.AreEqual(numDocs - 2, result.Length(), "all but ends");
-			
-			result = search.Search(q, new RangeFilter("id", medIP, maxIP, T, T));
-			Assert.AreEqual(1 + maxId - medId, result.Length(), "med and up");
-			
-			result = search.Search(q, new RangeFilter("id", minIP, medIP, T, T));
-			Assert.AreEqual(1 + medId - minId, result.Length(), "up to med");
-			
-			// unbounded id
-			
-			result = search.Search(q, new RangeFilter("id", minIP, null, T, F));
-			Assert.AreEqual(numDocs, result.Length(), "min and up");
-			
-			result = search.Search(q, new RangeFilter("id", null, maxIP, F, T));
-			Assert.AreEqual(numDocs, result.Length(), "max and down");
-			
-			result = search.Search(q, new RangeFilter("id", minIP, null, F, F));
-			Assert.AreEqual(numDocs - 1, result.Length(), "not min, but up");
-			
-			result = search.Search(q, new RangeFilter("id", null, maxIP, F, F));
-			Assert.AreEqual(numDocs - 1, result.Length(), "not max, but down");
-			
-			result = search.Search(q, new RangeFilter("id", medIP, maxIP, T, F));
-			Assert.AreEqual(maxId - medId, result.Length(), "med and up, not max");
-			
-			result = search.Search(q, new RangeFilter("id", minIP, medIP, F, T));
-			Assert.AreEqual(medId - minId, result.Length(), "not min, up to med");
-			
-			// very small sets
-			
-			result = search.Search(q, new RangeFilter("id", minIP, minIP, F, F));
-			Assert.AreEqual(0, result.Length(), "min,min,F,F");
-			result = search.Search(q, new RangeFilter("id", medIP, medIP, F, F));
-			Assert.AreEqual(0, result.Length(), "med,med,F,F");
-			result = search.Search(q, new RangeFilter("id", maxIP, maxIP, F, F));
-			Assert.AreEqual(0, result.Length(), "max,max,F,F");
-			
-			result = search.Search(q, new RangeFilter("id", minIP, minIP, T, T));
-			Assert.AreEqual(1, result.Length(), "min,min,T,T");
-			result = search.Search(q, new RangeFilter("id", null, minIP, F, T));
-			Assert.AreEqual(1, result.Length(), "nul,min,F,T");
-			
-			result = search.Search(q, new RangeFilter("id", maxIP, maxIP, T, T));
-			Assert.AreEqual(1, result.Length(), "max,max,T,T");
-			result = search.Search(q, new RangeFilter("id", maxIP, null, T, F));
-			Assert.AreEqual(1, result.Length(), "max,nul,T,T");
-			
-			result = search.Search(q, new RangeFilter("id", medIP, medIP, T, T));
-			Assert.AreEqual(1, result.Length(), "med,med,T,T");
-		}
-		
-		[Test]
-		public virtual void  TestRangeFilterRand()
-		{
-			
-			IndexReader reader = IndexReader.Open(index);
-			IndexSearcher search = new IndexSearcher(reader);
-			
-			System.String minRP = Pad(minR);
-			System.String maxRP = Pad(maxR);
-			
-			int numDocs = reader.NumDocs();
-			
-			Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs");
-			
-			Hits result;
-			Query q = new TermQuery(new Term("body", "body"));
-			
-			// test extremes, bounded on both ends
-			
-			result = search.Search(q, new RangeFilter("rand", minRP, maxRP, T, T));
-			Assert.AreEqual(numDocs, result.Length(), "find all");
-			
-			result = search.Search(q, new RangeFilter("rand", minRP, maxRP, T, F));
-			Assert.AreEqual(numDocs - 1, result.Length(), "all but biggest");
-			
-			result = search.Search(q, new RangeFilter("rand", minRP, maxRP, F, T));
-			Assert.AreEqual(numDocs - 1, result.Length(), "all but smallest");
-			
-			result = search.Search(q, new RangeFilter("rand", minRP, maxRP, F, F));
-			Assert.AreEqual(numDocs - 2, result.Length(), "all but extremes");
-			
-			// unbounded
-			
-			result = search.Search(q, new RangeFilter("rand", minRP, null, T, F));
-			Assert.AreEqual(numDocs, result.Length(), "smallest and up");
-			
-			result = search.Search(q, new RangeFilter("rand", null, maxRP, F, T));
-			Assert.AreEqual(numDocs, result.Length(), "biggest and down");
-			
-			result = search.Search(q, new RangeFilter("rand", minRP, null, F, F));
-			Assert.AreEqual(numDocs - 1, result.Length(), "not smallest, but up");
-			
-			result = search.Search(q, new RangeFilter("rand", null, maxRP, F, F));
-			Assert.AreEqual(numDocs - 1, result.Length(), "not biggest, but down");
-			
-			// very small sets
-			
-			result = search.Search(q, new RangeFilter("rand", minRP, minRP, F, F));
-			Assert.AreEqual(0, result.Length(), "min,min,F,F");
-			result = search.Search(q, new RangeFilter("rand", maxRP, maxRP, F, F));
-			Assert.AreEqual(0, result.Length(), "max,max,F,F");
-			
-			result = search.Search(q, new RangeFilter("rand", minRP, minRP, T, T));
-			Assert.AreEqual(1, result.Length(), "min,min,T,T");
-			result = search.Search(q, new RangeFilter("rand", null, minRP, F, T));
-			Assert.AreEqual(1, result.Length(), "nul,min,F,T");
-			
-			result = search.Search(q, new RangeFilter("rand", maxRP, maxRP, T, T));
-			Assert.AreEqual(1, result.Length(), "max,max,T,T");
-			result = search.Search(q, new RangeFilter("rand", maxRP, null, T, F));
-			Assert.AreEqual(1, result.Length(), "max,nul,T,T");
-		}
-	}
+    /// <summary> A basic 'positive' Unit test class for the RangeFilter class.
+    /// 
+    /// <p>
+    /// NOTE: at the moment, this class only tests for 'positive' results,
+    /// it does not verify the results to ensure there are no 'false positives',
+    /// nor does it adequately test 'negative' results.  It also does not test
+    /// that garbage in results in an Exception.
+    /// </summary>
+    [TestFixture]
+    public class TestRangeFilter : BaseTestRangeFilter
+    {
+
+        [Test]
+        public void TestRangeFilterId()
+        {
+
+            IndexReader reader = IndexReader.Open(signedIndex.index);
+            IndexSearcher search = new IndexSearcher(reader);
+
+            int medId = ((maxId - minId) / 2);
+
+            string minIP = Pad(minId);
+            string maxIP = Pad(maxId);
+            string medIP = Pad(medId);
+
+            int numDocs = reader.NumDocs();
+
+            Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs");
+
+            ScoreDoc[] result;
+            Query q = new TermQuery(new Term("body", "body"));
+
+            // test id, bounded on both ends
+
+            result = search.Search(q, new RangeFilter("id", minIP, maxIP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs, result.Length, "find all");
+
+            result = search.Search(q, new RangeFilter("id", minIP, maxIP, T, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 1, result.Length, "all but last");
+
+            result = search.Search(q, new RangeFilter("id", minIP, maxIP, F, T), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 1, result.Length, "all but first");
+
+            result = search.Search(q, new RangeFilter("id", minIP, maxIP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 2, result.Length, "all but ends");
+
+            result = search.Search(q, new RangeFilter("id", medIP, maxIP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(1 + maxId - medId, result.Length, "med and up");
+
+            result = search.Search(q, new RangeFilter("id", minIP, medIP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(1 + medId - minId, result.Length, "up to med");
+
+            // unbounded id
+
+            result = search.Search(q, new RangeFilter("id", minIP, null, T, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs, result.Length, "min and up");
+
+            result = search.Search(q, new RangeFilter("id", null, maxIP, F, T), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs, result.Length, "max and down");
+
+            result = search.Search(q, new RangeFilter("id", minIP, null, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 1, result.Length, "not min, but up");
+
+            result = search.Search(q, new RangeFilter("id", null, maxIP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 1, result.Length, "not max, but down");
+
+            result = search.Search(q, new RangeFilter("id", medIP, maxIP, T, F), numDocs).scoreDocs;
+            Assert.AreEqual(maxId - medId, result.Length, "med and up, not max");
+
+            result = search.Search(q, new RangeFilter("id", minIP, medIP, F, T), numDocs).scoreDocs;
+            Assert.AreEqual(medId - minId, result.Length, "not min, up to med");
+
+            // very small sets
+
+            result = search.Search(q, new RangeFilter("id", minIP, minIP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(0, result.Length, "min,min,F,F");
+            result = search.Search(q, new RangeFilter("id", medIP, medIP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(0, result.Length, "med,med,F,F");
+            result = search.Search(q, new RangeFilter("id", maxIP, maxIP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(0, result.Length, "max,max,F,F");
+
+            result = search.Search(q, new RangeFilter("id", minIP, minIP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "min,min,T,T");
+            result = search.Search(q, new RangeFilter("id", null, minIP, F, T), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "nul,min,F,T");
+
+            result = search.Search(q, new RangeFilter("id", maxIP, maxIP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "max,max,T,T");
+            result = search.Search(q, new RangeFilter("id", maxIP, null, T, F), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "max,nul,T,T");
+
+            result = search.Search(q, new RangeFilter("id", medIP, medIP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "med,med,T,T");
+
+        }
+
+        [Test]
+        public void TestRangeFilterIdCollating()
+        {
+
+            IndexReader reader = IndexReader.Open(signedIndex.index);
+            IndexSearcher search = new IndexSearcher(reader);
+
+            System.Globalization.CompareInfo c = System.Globalization.CultureInfo.GetCultureInfo("en-us").CompareInfo;
+
+            int medId = ((maxId - minId) / 2);
+
+            string minIP = Pad(minId);
+            string maxIP = Pad(maxId);
+            string medIP = Pad(medId);
+
+            int numDocs = reader.NumDocs();
+
+            Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs");
+
+            Hits result;
+            Query q = new TermQuery(new Term("body", "body"));
+
+            // test id, bounded on both ends
+
+            result = search.Search(q, new RangeFilter("id", minIP, maxIP, T, T, c));
+            Assert.AreEqual(numDocs, result.Length(), "find all");
+
+            result = search.Search(q, new RangeFilter("id", minIP, maxIP, T, F, c));
+            Assert.AreEqual(numDocs - 1, result.Length(), "all but last");
+
+            result = search.Search(q, new RangeFilter("id", minIP, maxIP, F, T, c));
+            Assert.AreEqual(numDocs - 1, result.Length(), "all but first");
+
+            result = search.Search(q, new RangeFilter("id", minIP, maxIP, F, F, c));
+            Assert.AreEqual(numDocs - 2, result.Length(), "all but ends");
+
+            result = search.Search(q, new RangeFilter("id", medIP, maxIP, T, T, c));
+            Assert.AreEqual(1 + maxId - medId, result.Length(), "med and up");
+
+            result = search.Search(q, new RangeFilter("id", minIP, medIP, T, T, c));
+            Assert.AreEqual(1 + medId - minId, result.Length(), "up to med");
+
+            // unbounded id
+
+            result = search.Search(q, new RangeFilter("id", minIP, null, T, F, c));
+            Assert.AreEqual(numDocs, result.Length(), "min and up");
+
+            result = search.Search(q, new RangeFilter("id", null, maxIP, F, T, c));
+            Assert.AreEqual(numDocs, result.Length(), "max and down");
+
+            result = search.Search(q, new RangeFilter("id", minIP, null, F, F, c));
+            Assert.AreEqual(numDocs - 1, result.Length(), "not min, but up");
+
+            result = search.Search(q, new RangeFilter("id", null, maxIP, F, F, c));
+            Assert.AreEqual(numDocs - 1, result.Length(), "not max, but down");
+
+            result = search.Search(q, new RangeFilter("id", medIP, maxIP, T, F, c));
+            Assert.AreEqual(maxId - medId, result.Length(), "med and up, not max");
+
+            result = search.Search(q, new RangeFilter("id", minIP, medIP, F, T, c));
+            Assert.AreEqual(medId - minId, result.Length(), "not min, up to med");
+
+            // very small sets
+
+            result = search.Search(q, new RangeFilter("id", minIP, minIP, F, F, c));
+            Assert.AreEqual(0, result.Length(), "min,min,F,F");
+            result = search.Search(q, new RangeFilter("id", medIP, medIP, F, F, c));
+            Assert.AreEqual(0, result.Length(), "med,med,F,F");
+            result = search.Search(q, new RangeFilter("id", maxIP, maxIP, F, F, c));
+            Assert.AreEqual(0, result.Length(), "max,max,F,F");
+
+            result = search.Search(q, new RangeFilter("id", minIP, minIP, T, T, c));
+            Assert.AreEqual(1, result.Length(), "min,min,T,T");
+            result = search.Search(q, new RangeFilter("id", null, minIP, F, T, c));
+            Assert.AreEqual(1, result.Length(), "nul,min,F,T");
+
+            result = search.Search(q, new RangeFilter("id", maxIP, maxIP, T, T, c));
+            Assert.AreEqual(1, result.Length(), "max,max,T,T");
+            result = search.Search(q, new RangeFilter("id", maxIP, null, T, F, c));
+            Assert.AreEqual(1, result.Length(), "max,nul,T,T");
+
+            result = search.Search(q, new RangeFilter("id", medIP, medIP, T, T, c));
+            Assert.AreEqual(1, result.Length(), "med,med,T,T");
+        }
+
+        [Test]
+        public void TestRangeFilterRand()
+        {
+
+            IndexReader reader = IndexReader.Open(signedIndex.index);
+            IndexSearcher search = new IndexSearcher(reader);
+
+            string minRP = Pad(signedIndex.minR);
+            string maxRP = Pad(signedIndex.maxR);
+
+            int numDocs = reader.NumDocs();
+
+            Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs");
+
+            ScoreDoc[] result;
+            Query q = new TermQuery(new Term("body", "body"));
+
+            // test extremes, bounded on both ends
+
+            result = search.Search(q, new RangeFilter("rand", minRP, maxRP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs, result.Length, "find all");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, maxRP, T, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 1, result.Length, "all but biggest");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, maxRP, F, T), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 1, result.Length, "all but smallest");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, maxRP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 2, result.Length, "all but extremes");
+
+            // unbounded
+
+            result = search.Search(q, new RangeFilter("rand", minRP, null, T, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs, result.Length, "smallest and up");
+
+            result = search.Search(q, new RangeFilter("rand", null, maxRP, F, T), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs, result.Length, "biggest and down");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, null, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 1, result.Length, "not smallest, but up");
+
+            result = search.Search(q, new RangeFilter("rand", null, maxRP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(numDocs - 1, result.Length, "not biggest, but down");
+
+            // very small sets
+
+            result = search.Search(q, new RangeFilter("rand", minRP, minRP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(0, result.Length, "min,min,F,F");
+            result = search.Search(q, new RangeFilter("rand", maxRP, maxRP, F, F), numDocs).scoreDocs;
+            Assert.AreEqual(0, result.Length, "max,max,F,F");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, minRP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "min,min,T,T");
+            result = search.Search(q, new RangeFilter("rand", null, minRP, F, T), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "nul,min,F,T");
+
+            result = search.Search(q, new RangeFilter("rand", maxRP, maxRP, T, T), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "max,max,T,T");
+            result = search.Search(q, new RangeFilter("rand", maxRP, null, T, F), numDocs).scoreDocs;
+            Assert.AreEqual(1, result.Length, "max,nul,T,T");
+
+        }
+
+        [Test]
+        public void TestRangeFilterRandCollating()
+        {
+
+            // using the unsigned index because collation seems to ignore hyphens
+            IndexReader reader = IndexReader.Open(unsignedIndex.index);
+            IndexSearcher search = new IndexSearcher(reader);
+
+            System.Globalization.CompareInfo c = System.Globalization.CultureInfo.GetCultureInfo("en-us").CompareInfo;
+
+            string minRP = Pad(unsignedIndex.minR);
+            string maxRP = Pad(unsignedIndex.maxR);
+
+            int numDocs = reader.NumDocs();
+
+            Assert.AreEqual(numDocs, 1 + maxId - minId, "num of docs");
+
+            Hits result;
+            Query q = new TermQuery(new Term("body", "body"));
+
+            // test extremes, bounded on both ends
+
+            result = search.Search(q, new RangeFilter("rand", minRP, maxRP, T, T, c));
+            Assert.AreEqual(numDocs, result.Length(), "find all");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, maxRP, T, F, c));
+            Assert.AreEqual(numDocs - 1, result.Length(), "all but biggest");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, maxRP, F, T, c));
+            Assert.AreEqual(numDocs - 1, result.Length(), "all but smallest");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, maxRP, F, F, c));
+            Assert.AreEqual(numDocs - 2, result.Length(), "all but extremes");
+
+            // unbounded
+
+            result = search.Search(q, new RangeFilter("rand", minRP, null, T, F, c));
+            Assert.AreEqual(numDocs, result.Length(), "smallest and up");
+
+            result = search.Search(q, new RangeFilter("rand", null, maxRP, F, T, c));
+            Assert.AreEqual(numDocs, result.Length(), "biggest and down");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, null, F, F, c));
+            Assert.AreEqual(numDocs - 1, result.Length(), "not smallest, but up");
+
+            result = search.Search(q, new RangeFilter("rand", null, maxRP, F, F, c));
+            Assert.AreEqual(numDocs - 1, result.Length(), "not biggest, but down");
+
+            // very small sets
+
+            result = search.Search(q, new RangeFilter("rand", minRP, minRP, F, F, c));
+            Assert.AreEqual(0, result.Length(), "min,min,F,F");
+            result = search.Search(q, new RangeFilter("rand", maxRP, maxRP, F, F, c));
+            Assert.AreEqual(0, result.Length(), "max,max,F,F");
+
+            result = search.Search(q, new RangeFilter("rand", minRP, minRP, T, T, c));
+            Assert.AreEqual(1, result.Length(), "min,min,T,T");
+            result = search.Search(q, new RangeFilter("rand", null, minRP, F, T, c));
+            Assert.AreEqual(1, result.Length(), "nul,min,F,T");
+
+            result = search.Search(q, new RangeFilter("rand", maxRP, maxRP, T, T, c));
+            Assert.AreEqual(1, result.Length(), "max,max,T,T");
+            result = search.Search(q, new RangeFilter("rand", maxRP, null, T, F, c));
+            Assert.AreEqual(1, result.Length(), "max,nul,T,T");
+        }
+
+        [Test]
+        public void TestFarsi()
+        {
+
+            /* build an index */
+            RAMDirectory farsiIndex = new RAMDirectory();
+            IndexWriter writer = new IndexWriter(farsiIndex, new SimpleAnalyzer(), T,
+                                                 IndexWriter.MaxFieldLength.LIMITED);
+            Document doc = new Document();
+            doc.Add(new Field("content", "\u0633\u0627\u0628",
+                              Field.Store.YES, Field.Index.UN_TOKENIZED));
+            doc.Add(new Field("body", "body",
+                              Field.Store.YES, Field.Index.UN_TOKENIZED));
+            writer.AddDocument(doc);
+
+            writer.Optimize();
+            writer.Close();
+
+            IndexReader reader = IndexReader.Open(farsiIndex);
+            IndexSearcher search = new IndexSearcher(reader);
+            Query q = new TermQuery(new Term("body", "body"));
+
+            // Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
+            // RuleBasedCollator.  However, the Arabic Locale seems to order the Farsi
+            // characters properly.
+            System.Globalization.CompareInfo collator = System.Globalization.CultureInfo.GetCultureInfo("ar").CompareInfo;
+
+            // Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
+            // orders the U+0698 character before the U+0633 character, so the single
+            // index Term below should NOT be returned by a RangeFilter with a Farsi
+            // Collator (or an Arabic one for the case when Farsi is not supported).
+            Hits result = search.Search
+                (q, new RangeFilter("content", "\u062F", "\u0698", T, T, collator));
+            Assert.AreEqual(0, result.Length(), "The index Term should not be included.");
+
+            result = search.Search
+                (q, new RangeFilter("content", "\u0633", "\u0638", T, T, collator));
+            Assert.AreEqual(1, result.Length(), "The index Term should be included.");
+            search.Close();
+        }
+    }
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestRangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestRangeQuery.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestRangeQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestRangeQuery.cs Wed Jul 29 18:04:12 2009
@@ -157,8 +157,8 @@
 		{
 			Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
 			
-			doc.Add(new Field("id", "id" + docCount, Field.Store.YES, Field.Index.UN_TOKENIZED));
-			doc.Add(new Field("content", content, Field.Store.NO, Field.Index.TOKENIZED));
+			doc.Add(new Field("id", "id" + docCount, Field.Store.YES, Field.Index.NOT_ANALYZED));
+			doc.Add(new Field("content", content, Field.Store.NO, Field.Index.ANALYZED));
 			
 			writer.AddDocument(doc);
 			docCount++;

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteCachingWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestRemoteCachingWrapperFilter.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteCachingWrapperFilter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteCachingWrapperFilter.cs Wed Jul 29 18:04:12 2009
@@ -33,8 +33,6 @@
 	/// <summary> Tests that the index is cached on the searcher side of things.
 	/// NOTE: This is copied from TestRemoteSearchable since it already had a remote index set up.
 	/// </summary>
-	/// <author>  Matt Ericson
-	/// </author>
 	[TestFixture]
 	public class TestRemoteCachingWrapperFilter : LuceneTestCase
 	{
@@ -87,19 +85,19 @@
 
 			// construct an index
 			RAMDirectory indexStore = new RAMDirectory();
-			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true);
+			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 
 			Document doc = new Document();
-			doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.TOKENIZED));
-			doc.Add(new Field("type", "A", Field.Store.YES, Field.Index.TOKENIZED));
-			doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.TOKENIZED));
+			doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
+			doc.Add(new Field("type", "A", Field.Store.YES, Field.Index.ANALYZED));
+			doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
 			writer.AddDocument(doc);
 
 			//Need a second document to search for
 			doc = new Document();
-			doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.TOKENIZED));
-			doc.Add(new Field("type", "B", Field.Store.YES, Field.Index.TOKENIZED));
-			doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.TOKENIZED));
+			doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
+			doc.Add(new Field("type", "B", Field.Store.YES, Field.Index.ANALYZED));
+			doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
 			writer.AddDocument(doc);
 
 			writer.Optimize();
@@ -148,15 +146,15 @@
 		//    RAMDirectory indexStore = new RAMDirectory();
 		//    IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true);
 		//    Document doc = new Document();
-		//    doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.TOKENIZED));
-		//    doc.Add(new Field("type", "A", Field.Store.YES, Field.Index.TOKENIZED));
-		//    doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.TOKENIZED));
+		//    doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
+		//    doc.Add(new Field("type", "A", Field.Store.YES, Field.Index.ANALYZED));
+		//    doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
 		//    writer.AddDocument(doc);
 		//    //Need a second document to search for
 		//    doc = new Document();
-		//    doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.TOKENIZED));
-		//    doc.Add(new Field("type", "B", Field.Store.YES, Field.Index.TOKENIZED));
-		//    doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.TOKENIZED));
+		//    doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
+		//    doc.Add(new Field("type", "B", Field.Store.YES, Field.Index.ANALYZED));
+		//    doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
 		//    writer.AddDocument(doc);
 		//    writer.Optimize();
 		//    writer.Close();
@@ -182,9 +180,9 @@
 		{
 			Lucene.Net.Search.Searchable[] searchables = new Lucene.Net.Search.Searchable[]{GetRemote()};
 			Searcher searcher = new MultiSearcher(searchables);
-			Hits result = searcher.Search(query, filter);
-			Assert.AreEqual(1, result.Length());
-			Document document = result.Doc(hitNumber);
+			ScoreDoc[] result = searcher.Search(query, filter, 1000).scoreDocs;
+			Assert.AreEqual(1, result.Length);
+			Document document = searcher.Doc(result[hitNumber].doc);
 			Assert.IsTrue(document != null, "document is null and it shouldn't be");
 			Assert.AreEqual(typeValue, document.Get("type"));
 			Assert.IsTrue(document.GetFields().Count == 3, "document.getFields() Size: " + document.GetFields().Count + " is not: " + 3);
@@ -194,7 +192,7 @@
 		[Test]
 		public virtual void  TestTermRemoteFilter()
 		{
-			CachingWrapperFilterHelper cwfh = new CachingWrapperFilterHelper(new QueryFilter(new TermQuery(new Term("type", "a"))));
+			CachingWrapperFilterHelper cwfh = new CachingWrapperFilterHelper(new QueryWrapperFilter(new TermQuery(new Term("type", "a"))));
 			
 			// This is what we are fixing - if one uses a CachingWrapperFilter(Helper) it will never 
 			// cache the filter on the remote site
@@ -215,16 +213,16 @@
 			// assert that we get the same cached Filter, even if we create a new instance of RemoteCachingWrapperFilter(Helper)
 			// this should pass because the Filter parameters are the same, and the cache uses Filter's hashCode() as cache keys,
 			// and Filters' hashCode() builds on Filter parameters, not the Filter instance itself
-			rcwfh = new RemoteCachingWrapperFilterHelper(new QueryFilter(new TermQuery(new Term("type", "a"))), false);
+			rcwfh = new RemoteCachingWrapperFilterHelper(new QueryWrapperFilter(new TermQuery(new Term("type", "a"))), false);
 			rcwfh.ShouldHaveCache(false);
 			Search(new TermQuery(new Term("test", "test")), rcwfh, 0, "A");
-			
-			rcwfh = new RemoteCachingWrapperFilterHelper(new QueryFilter(new TermQuery(new Term("type", "a"))), false);
+
+            rcwfh = new RemoteCachingWrapperFilterHelper(new QueryWrapperFilter(new TermQuery(new Term("type", "a"))), false);
 			rcwfh.ShouldHaveCache(true);
 			Search(new TermQuery(new Term("test", "test")), rcwfh, 0, "A");
 			
 			// assert that we get a non-cached version of the Filter because this is a new Query (type:b)
-			rcwfh = new RemoteCachingWrapperFilterHelper(new QueryFilter(new TermQuery(new Term("type", "b"))), false);
+            rcwfh = new RemoteCachingWrapperFilterHelper(new QueryWrapperFilter(new TermQuery(new Term("type", "b"))), false);
 			rcwfh.ShouldHaveCache(false);
 			Search(new TermQuery(new Term("type", "b")), rcwfh, 0, "B");
 		}

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestRemoteSearchable.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs Wed Jul 29 18:04:12 2009
@@ -34,32 +34,34 @@
 	[TestFixture]
 	public class TestRemoteSearchable : LuceneTestCase
 	{
-		private static readonly string RemoteTypeName = typeof(RemoteSearchable).Name;
 		private static System.Runtime.Remoting.Channels.Http.HttpChannel httpChannel;
+		private static int port;
 		private static bool serverStarted;
 
-		[TestFixtureSetUp]
-		public void FixtureSetup()
+		[SetUp]
+		public override void SetUp()
 		{
-			if (!serverStarted) //should always evaluate to true
-			{
-				httpChannel = new System.Runtime.Remoting.Channels.Http.HttpChannel(0);
+			base.SetUp();
+			Random rnd = new Random((int)(DateTime.Now.Ticks & 0x7fffffff));
+			port = rnd.Next(System.Net.IPEndPoint.MinPort, System.Net.IPEndPoint.MaxPort);
+			httpChannel = new System.Runtime.Remoting.Channels.Http.HttpChannel(port);
+			if (!serverStarted)
 				StartServer();
-			}
 		}
 
-		[TestFixtureTearDown]
-		public void FixtureTeardown()
+		[TearDown]
+		public override void TearDown()
 		{
-			try
-			{
-				System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(httpChannel);
-			}
-			catch
-			{
-			}
+            try
+            {
+                System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(httpChannel);
+            }
+            catch
+            {
+            }
 
-			httpChannel = null;
+            httpChannel = null;
+			base.TearDown();
 		}
 
 		private static Lucene.Net.Search.Searchable GetRemote()
@@ -69,7 +71,7 @@
 
 		private static Lucene.Net.Search.Searchable LookupRemote()
 		{
-			return (Lucene.Net.Search.Searchable)Activator.GetObject(typeof(Lucene.Net.Search.Searchable), httpChannel.GetUrlsForUri(RemoteTypeName)[0]);
+			return (Lucene.Net.Search.Searchable)Activator.GetObject(typeof(Lucene.Net.Search.Searchable), string.Format("http://localhost:{0}/RemoteSearchable", port));
 		}
 
 		public static void StartServer()
@@ -92,11 +94,11 @@
 
 			// construct an index
 			RAMDirectory indexStore = new RAMDirectory();
-			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true);
+			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 
 			Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
-			doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.TOKENIZED));
-			doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.TOKENIZED));
+			doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
+			doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
 			writer.AddDocument(doc);
 
 			writer.Optimize();
@@ -105,7 +107,7 @@
 			// publish it
 			Lucene.Net.Search.Searchable local = new IndexSearcher(indexStore);
 			RemoteSearchable impl = new RemoteSearchable(local);
-			System.Runtime.Remoting.RemotingServices.Marshal(impl, RemoteTypeName);
+			System.Runtime.Remoting.RemotingServices.Marshal(impl, "RemoteSearchable");
 			serverStarted = true;
 		}
 		
@@ -145,8 +147,8 @@
 		//    RAMDirectory indexStore = new RAMDirectory();
 		//    IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true);
 		//    Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
-		//    doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.TOKENIZED));
-		//    doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.TOKENIZED));
+		//    doc.Add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
+		//    doc.Add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
 		//    writer.AddDocument(doc);
 		//    writer.Optimize();
 		//    writer.Close();
@@ -162,10 +164,10 @@
 			// try to search the published index
 			Lucene.Net.Search.Searchable[] searchables = new Lucene.Net.Search.Searchable[]{GetRemote()};
 			Searcher searcher = new MultiSearcher(searchables);
-			Hits result = searcher.Search(query);
+            ScoreDoc[] result = searcher.Search(query, null, 1000).scoreDocs;
 			
-			Assert.AreEqual(1, result.Length());
-			Document document = result.Doc(0);
+			Assert.AreEqual(1, result.Length);
+			Document document = searcher.Doc(result[0].doc);
 			Assert.IsTrue(document != null, "document is null and it shouldn't be");
 			Assert.AreEqual(document.Get("test"), "test text");
 			Assert.IsTrue(document.GetFields().Count == 2, "document.getFields() Size: " + document.GetFields().Count + " is not: " + 2);
@@ -211,10 +213,10 @@
 			// try to search the published index
 			Lucene.Net.Search.Searchable[] searchables = new Lucene.Net.Search.Searchable[]{GetRemote()};
 			Searcher searcher = new MultiSearcher(searchables);
-			Hits hits = searcher.Search(new TermQuery(new Term("test", "text")), new QueryFilter(new TermQuery(new Term("test", "test"))));
-			Assert.AreEqual(1, hits.Length());
-			Hits nohits = searcher.Search(new TermQuery(new Term("test", "text")), new QueryFilter(new TermQuery(new Term("test", "non-existent-term"))));
-			Assert.AreEqual(0, nohits.Length());
+			ScoreDoc[] hits = searcher.Search(new TermQuery(new Term("test", "text")), new QueryWrapperFilter(new TermQuery(new Term("test", "test"))), 1000).scoreDocs;
+			Assert.AreEqual(1, hits.Length);
+            ScoreDoc[] nohits = searcher.Search(new TermQuery(new Term("test", "text")), new QueryWrapperFilter(new TermQuery(new Term("test", "non-existent-term"))), 1000).scoreDocs;
+			Assert.AreEqual(0, nohits.Length);
 		}
 		
 		[Test]
@@ -223,8 +225,8 @@
 			// try to search the published index
 			Lucene.Net.Search.Searchable[] searchables = new Lucene.Net.Search.Searchable[]{GetRemote()};
 			Searcher searcher = new MultiSearcher(searchables);
-			Hits hits = searcher.Search(new ConstantScoreQuery(new QueryFilter(new TermQuery(new Term("test", "test")))));
-			Assert.AreEqual(1, hits.Length());
+            ScoreDoc[] hits = searcher.Search(new ConstantScoreQuery(new QueryWrapperFilter(new TermQuery(new Term("test", "test")))), 1000).scoreDocs;
+			Assert.AreEqual(1, hits.Length);
 		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestScorerPerf.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestScorerPerf.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestScorerPerf.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestScorerPerf.cs Wed Jul 29 18:04:12 2009
@@ -28,6 +28,7 @@
 using RAMDirectory = Lucene.Net.Store.RAMDirectory;
 using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
 using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
+using DocIdBitSet = Lucene.Net.Util.DocIdBitSet;
 
 namespace Lucene.Net.Search
 {
@@ -50,7 +51,7 @@
 			// Create a dummy index with nothing in it.
 			// This could possibly fail if Lucene starts checking for docid ranges...
 			RAMDirectory rd = new RAMDirectory();
-			IndexWriter iw = new IndexWriter(rd, new WhitespaceAnalyzer(), true);
+			IndexWriter iw = new IndexWriter(rd, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			iw.Close();
 			s = new IndexSearcher(rd);
 		}
@@ -64,8 +65,8 @@
 				freq[i] = (int) System.Math.Ceiling(System.Math.Pow(f, power));
 				terms[i] = new Term("f", System.Convert.ToString((char) ('A' + i)));
 			}
-			
-			IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
+
+            IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			for (int i = 0; i < nDocs; i++)
 			{
 				Document d = new Document();
@@ -73,7 +74,7 @@
 				{
 					if (r.Next(freq[j]) == 0)
 					{
-						d.Add(new Field("f", terms[j].Text(), Field.Store.NO, Field.Index.UN_TOKENIZED));
+						d.Add(new Field("f", terms[j].Text(), Field.Store.NO, Field.Index.NOT_ANALYZED));
 						//System.out.println(d);
 					}
 				}
@@ -104,20 +105,6 @@
 			return sets;
 		}
 		
-		[Serializable]
-		public class BitSetFilter : Filter
-		{
-			public System.Collections.BitArray set_Renamed;
-			public BitSetFilter(System.Collections.BitArray set_Renamed)
-			{
-				this.set_Renamed = set_Renamed;
-			}
-			public override System.Collections.BitArray Bits(IndexReader reader)
-			{
-				return set_Renamed;
-			}
-		}
-		
 		public class CountingHitCollector : HitCollector
 		{
 			internal int count = 0;
@@ -160,11 +147,28 @@
 			}
 		}
 		
-		
+		public class AnonymousClassFilter : Filter
+        {
+            private System.Collections.BitArray rnd;
+            public AnonymousClassFilter(System.Collections.BitArray rnd)
+            {
+                this.rnd = rnd;
+            }
+            override public DocIdSet GetDocIdSet(IndexReader reader)
+            {
+                return new DocIdBitSet(rnd);
+            }
+            [System.Obsolete()]
+            override public System.Collections.BitArray Bits(IndexReader reader)
+            {
+                return null;
+            }
+        }
+
 		internal virtual System.Collections.BitArray AddClause(BooleanQuery bq, System.Collections.BitArray result)
 		{
 			System.Collections.BitArray rnd = sets[r.Next(sets.Length)];
-			Query q = new ConstantScoreQuery(new BitSetFilter(rnd));
+			Query q = new ConstantScoreQuery(new AnonymousClassFilter(rnd));
 			bq.Add(q, BooleanClause.Occur.MUST);
 			if (validate)
 			{

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestSearchHitsWithDeletions.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestSearchHitsWithDeletions.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestSearchHitsWithDeletions.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestSearchHitsWithDeletions.cs Wed Jul 29 18:04:12 2009
@@ -35,6 +35,7 @@
 	/// 
 	/// See {@link http://issues.apache.org/jira/browse/LUCENE-1096}.
 	/// </summary>
+    [System.Obsolete("Hits will be removed in Lucene 3.0")]
 	[TestFixture]
 	public class TestSearchHitsWithDeletions
 	{
@@ -50,7 +51,7 @@
 		{
 			// Create an index writer.
 			directory = new RAMDirectory();
-			IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
+			IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			for (int i = 0; i < N; i++)
 			{
 				writer.AddDocument(CreateDocument(i));
@@ -184,7 +185,7 @@
 		private static Document CreateDocument(int id)
 		{
 			Document doc = new Document();
-			doc.Add(new Field(TEXT_FIELD, "text of document" + id, Field.Store.YES, Field.Index.TOKENIZED));
+			doc.Add(new Field(TEXT_FIELD, "text of document" + id, Field.Store.YES, Field.Index.ANALYZED));
 			return doc;
 		}
 		

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestSetNorm.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestSetNorm.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestSetNorm.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestSetNorm.cs Wed Jul 29 18:04:12 2009
@@ -71,10 +71,10 @@
 		public virtual void  TestSetNorm_Renamed_Method()
 		{
 			RAMDirectory store = new RAMDirectory();
-			IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true);
+			IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			
 			// add the same document four times
-			Fieldable f1 = new Field("field", "word", Field.Store.YES, Field.Index.TOKENIZED);
+			Fieldable f1 = new Field("field", "word", Field.Store.YES, Field.Index.ANALYZED);
 			Lucene.Net.Documents.Document d1 = new Lucene.Net.Documents.Document();
 			d1.Add(f1);
 			writer.AddDocument(d1);

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestSimilarity.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestSimilarity.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestSimilarity.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestSimilarity.cs Wed Jul 29 18:04:12 2009
@@ -180,14 +180,14 @@
 		public virtual void  TestSimilarity_Renamed_Method()
 		{
 			RAMDirectory store = new RAMDirectory();
-			IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true);
+			IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			writer.SetSimilarity(new SimpleSimilarity());
 			
 			Lucene.Net.Documents.Document d1 = new Lucene.Net.Documents.Document();
-			d1.Add(new Field("field", "a c", Field.Store.YES, Field.Index.TOKENIZED));
+			d1.Add(new Field("field", "a c", Field.Store.YES, Field.Index.ANALYZED));
 			
 			Lucene.Net.Documents.Document d2 = new Lucene.Net.Documents.Document();
-			d2.Add(new Field("field", "a b c", Field.Store.YES, Field.Index.TOKENIZED));
+			d2.Add(new Field("field", "a b c", Field.Store.YES, Field.Index.ANALYZED));
 			
 			writer.AddDocument(d1);
 			writer.AddDocument(d2);

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestSimpleExplanations.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestSimpleExplanations.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestSimpleExplanations.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestSimpleExplanations.cs Wed Jul 29 18:04:12 2009
@@ -313,7 +313,7 @@
 			Qtest(q, new int[]{0, 1, 2, 3});
 		}
 		
-		/* some simple tests of boolean queries containing term queries */
+		/* some simple tests of bool queries containing term queries */
 		
 		[Test]
 		public virtual void  TestBQ1()

Added: incubator/lucene.net/trunk/C#/src/Test/Search/TestSloppyPhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestSloppyPhraseQuery.cs?rev=798995&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestSloppyPhraseQuery.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestSloppyPhraseQuery.cs Wed Jul 29 18:04:12 2009
@@ -0,0 +1,177 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 NUnit.Framework;
+
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using Term = Lucene.Net.Index.Term;
+using MaxFieldLength = Lucene.Net.Index.IndexWriter.MaxFieldLength;
+using IndexSearcher = Lucene.Net.Search.IndexSearcher;
+using PhraseQuery = Lucene.Net.Search.PhraseQuery;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+
+namespace Lucene.Net.Search
+{
+    [TestFixture]
+    public class TestSloppyPhraseQuery
+    {
+
+        private static readonly string S_1 = "A A A";
+        private static readonly string S_2 = "A 1 2 3 A 4 5 6 A";
+
+        private static readonly Document DOC_1 = makeDocument("X " + S_1 + " Y");
+        private static readonly Document DOC_2 = makeDocument("X " + S_2 + " Y");
+        private static readonly Document DOC_3 = makeDocument("X " + S_1 + " A Y");
+        private static readonly Document DOC_1_B = makeDocument("X " + S_1 + " Y N N N N " + S_1 + " Z");
+        private static readonly Document DOC_2_B = makeDocument("X " + S_2 + " Y N N N N " + S_2 + " Z");
+        private static readonly Document DOC_3_B = makeDocument("X " + S_1 + " A Y N N N N " + S_1 + " A Y");
+        private static readonly Document DOC_4 = makeDocument("A A X A X B A X B B A A X B A A");
+
+        private static readonly PhraseQuery QUERY_1 = makePhraseQuery(S_1);
+        private static readonly PhraseQuery QUERY_2 = makePhraseQuery(S_2);
+        private static readonly PhraseQuery QUERY_4 = makePhraseQuery("X A A");
+
+        /**
+         * Test DOC_4 and QUERY_4.
+         * QUERY_4 has a fuzzy (len=1) match to DOC_4, so all slop values > 0 should succeed.
+         * But only the 3rd sequence of A's in DOC_4 will do.
+         */
+        [Test]
+        public void TestDoc4_Query4_All_Slops_Should_match()
+        {
+            for (int slop = 0; slop < 30; slop++)
+            {
+                int numResultsExpected = slop < 1 ? 0 : 1;
+                checkPhraseQuery(DOC_4, QUERY_4, slop, numResultsExpected);
+            }
+        }
+
+        /**
+         * Test DOC_1 and QUERY_1.
+         * QUERY_1 has an exact match to DOC_1, so all slop values should succeed.
+         * Before LUCENE-1310, a slop value of 1 did not succeed.
+         */
+        [Test]
+        public void TestDoc1_Query1_All_Slops_Should_match()
+        {
+            for (int slop = 0; slop < 30; slop++)
+            {
+                float score1 = checkPhraseQuery(DOC_1, QUERY_1, slop, 1);
+                float score2 = checkPhraseQuery(DOC_1_B, QUERY_1, slop, 1);
+                Assert.IsTrue(score2 > score1, "slop=" + slop + " score2=" + score2 + " should be greater than score1 " + score1);
+            }
+        }
+
+        /**
+         * Test DOC_2 and QUERY_1.
+         * 6 should be the minimum slop to make QUERY_1 match DOC_2.
+         * Before LUCENE-1310, 7 was the minimum.
+         */
+        [Test]
+        public void TestDoc2_Query1_Slop_6_or_more_Should_match()
+        {
+            for (int slop = 0; slop < 30; slop++)
+            {
+                int numResultsExpected = slop < 6 ? 0 : 1;
+                float score1 = checkPhraseQuery(DOC_2, QUERY_1, slop, numResultsExpected);
+                if (numResultsExpected > 0)
+                {
+                    float score2 = checkPhraseQuery(DOC_2_B, QUERY_1, slop, 1);
+                    Assert.IsTrue(score2 > score1, "slop=" + slop + " score2=" + score2 + " should be greater than score1 " + score1);
+                }
+            }
+        }
+
+        /**
+         * Test DOC_2 and QUERY_2.
+         * QUERY_2 has an exact match to DOC_2, so all slop values should succeed.
+         * Before LUCENE-1310, 0 succeeds, 1 through 7 fail, and 8 or greater succeeds.
+         */
+        [Test]
+        public void TestDoc2_Query2_All_Slops_Should_match()
+        {
+            for (int slop = 0; slop < 30; slop++)
+            {
+                float score1 = checkPhraseQuery(DOC_2, QUERY_2, slop, 1);
+                float score2 = checkPhraseQuery(DOC_2_B, QUERY_2, slop, 1);
+                Assert.IsTrue(score2 > score1, "slop=" + slop + " score2=" + score2 + " should be greater than score1 " + score1);
+            }
+        }
+
+        /**
+         * Test DOC_3 and QUERY_1.
+         * QUERY_1 has an exact match to DOC_3, so all slop values should succeed.
+         */
+        [Test]
+        public void TestDoc3_Query1_All_Slops_Should_match()
+        {
+            for (int slop = 0; slop < 30; slop++)
+            {
+                float score1 = checkPhraseQuery(DOC_3, QUERY_1, slop, 1);
+                float score2 = checkPhraseQuery(DOC_3_B, QUERY_1, slop, 1);
+                Assert.IsTrue(score2 > score1, "slop=" + slop + " score2=" + score2 + " should be greater than score1 " + score1);
+            }
+        }
+
+        private float checkPhraseQuery(Document doc, PhraseQuery query, int slop, int expectedNumResults)
+        {
+            query.SetSlop(slop);
+
+            RAMDirectory ramDir = new RAMDirectory();
+            WhitespaceAnalyzer analyzer = new WhitespaceAnalyzer();
+            IndexWriter writer = new IndexWriter(ramDir, analyzer, MaxFieldLength.UNLIMITED);
+            writer.AddDocument(doc);
+            writer.Close();
+
+            IndexSearcher searcher = new IndexSearcher(ramDir);
+            TopDocs td = searcher.Search(query, null, 10);
+            //System.out.println("slop: "+slop+"  query: "+query+"  doc: "+doc+"  Expecting number of hits: "+expectedNumResults+" maxScore="+td.getMaxScore());
+            Assert.AreEqual(expectedNumResults, td.totalHits, "slop: " + slop + "  query: " + query + "  doc: " + doc + "  Wrong number of hits");
+
+            //QueryUtils.check(query,searcher);
+
+            searcher.Close();
+            ramDir.Close();
+
+            return td.GetMaxScore();
+        }
+
+        private static Document makeDocument(string docText)
+        {
+            Document doc = new Document();
+            Field f = new Field("f", docText, Field.Store.NO, Field.Index.ANALYZED);
+            f.SetOmitNorms(true);
+            doc.Add(f);
+            return doc;
+        }
+
+        private static PhraseQuery makePhraseQuery(string terms)
+        {
+            PhraseQuery query = new PhraseQuery();
+            string[] t = terms.Split(new string[] { " " }, System.StringSplitOptions.RemoveEmptyEntries);
+            for (int i = 0; i < t.Length; i++)
+            {
+                query.Add(new Term("f", t[i]));
+            }
+            return query;
+        }
+
+    }
+}

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestSort.cs?rev=798995&r1=798994&r2=798995&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs Wed Jul 29 18:04:12 2009
@@ -16,18 +16,18 @@
  */
 
 using System;
+using Pattern = System.Text.RegularExpressions.Regex;
 
 using NUnit.Framework;
 
+using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
 using Document = Lucene.Net.Documents.Document;
 using Field = Lucene.Net.Documents.Field;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using IndexWriter = Lucene.Net.Index.IndexWriter;
 using Term = Lucene.Net.Index.Term;
 using RAMDirectory = Lucene.Net.Store.RAMDirectory;
-using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
-
-using Pattern = System.Text.RegularExpressions.Regex;
+using DocIdBitSet = Lucene.Net.Util.DocIdBitSet;
 
 namespace Lucene.Net.Search
 {
@@ -37,8 +37,6 @@
 	/// <p>Created: Feb 17, 2004 4:55:10 PM
 	/// 
 	/// </summary>
-	/// <author>   Tim Jones (Nacimiento Software)
-	/// </author>
 	/// <since>   lucene 1.4
 	/// </since>
 	/// <version>  $Id: TestSort.java 590530 2007-10-31 01:28:25Z gsingers $
@@ -73,7 +71,14 @@
 				
 			}
 
-			public override System.Collections.BitArray Bits(IndexReader reader)
+            public override DocIdSet GetDocIdSet(IndexReader reader)
+            {
+                System.Collections.BitArray bs = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0 ? reader.MaxDoc() / 64 : reader.MaxDoc() / 64 + 1) * 64);
+                bs.Set(docs1.scoreDocs[0].doc, true);
+                return new DocIdBitSet(bs);
+            }
+            [System.Obsolete()]
+            public override System.Collections.BitArray Bits(IndexReader reader)
 			{
 				System.Collections.BitArray bs = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
 				bs.Set(docs1.scoreDocs[0].doc, true);
@@ -135,52 +140,70 @@
 		// the float field to sort by float
 		// the string field to sort by string
 		// the i18n field includes accented characters for testing locale-specific sorting
-		private System.String[][] data = new System.String[][]{
-							   // tracer  contents         int            float                     string   custom   i18n                  long             double
-			new System.String[]{   "A",   "x a",           "5",           "4f",                     "c",     "A-3",   "p\u00EAche",         "10",            "-4" + NDS + "0"}, 
-			new System.String[]{   "B",   "y a",           "5",           "3" + NDS + "4028235E38", "i",     "B-10",  "HAT",                "1000000000",    "40" + NDS + "0"}, 
-			new System.String[]{   "C",   "x a b c",       "2147483647",  "1" + NDS + "0",          "j",     "A-2",   "p\u00E9ch\u00E9",    "99999999",      "40" + NDS + "00002343"}, 
-			//new System.String[]{   "D",   "y a b c",       "-1",          "0" + NDS + "0f",         "a",     "C-0",   "HUT",                System.Convert.ToString(System.Int64.MaxValue), System.Convert.ToString(System.Double.MinValue)}, 
-			//new System.String[]{   "E",   "x a b c d",     "5",           "2f",                     "h",     "B-8",   "peach",              System.Convert.ToString(System.Int64.MinValue), System.Convert.ToString(System.Double.MaxValue)}, 
-			new System.String[]{   "D",   "y a b c",       "-1",          "0" + NDS + "0f",         "a",     "C-0",   "HUT",                System.Convert.ToString(System.Int64.MaxValue), System.Double.MinValue.ToString("R")}, 
-			new System.String[]{   "E",   "x a b c d",     "5",           "2f",                     "h",     "B-8",   "peach",              System.Convert.ToString(System.Int64.MinValue), System.Double.MaxValue.ToString("R")}, 
-			new System.String[]{   "F",   "y a b c d",     "2",           "3" + NDS + "14159f",     "g",     "B-1",   "H\u00C5T",           "-44",           "343" + NDS + "034435444"}, 
-			new System.String[]{   "G",   "x a b c d",     "3",           "-1" + NDS + "0",         "f",     "C-100", "sin",                "323254543543",  "4" + NDS + "043544"}, 
-			new System.String[]{   "H",   "y a b c d",     "0",           "1" + NDS + "4E-45",      "e",     "C-88",  "H\u00D8T",           "1023423423005", "4" + NDS + "043545"}, 
-			new System.String[]{   "I",   "x a b c d e f", "-2147483648", "1" + NDS + "0e+0",       "d",     "A-10",  "s\u00EDn",           "332422459999",  "4" + NDS + "043546"}, 
-			new System.String[]{   "J",   "y a b c d e f", "4",           "" + NDS + "5",           "b",     "C-7",   "HOT",                "34334543543",   "4" + NDS + "0000220343"}, 
-			new System.String[]{   "W",   "g",             "1",           null,                     null,    null,    null,                 null,            null}, 
-			new System.String[]{   "X",   "g",             "1",           "0" + NDS + "1",          null,    null,    null,                 null,            null}, 
-			new System.String[]{   "Y",   "g",             "1",           "0" + NDS + "2",          null,    null,    null,                 null,            null}, 
-			new System.String[]{   "Z",   "f g",           null,          null,                     null,    null,    null,                 null,            null}};
+		private string[][] data = new string[][] {
+
+            // {dougsale-2.4.0}
+            // As C# doesn't support a signed byte datatype, the byte values of the data array have been adjusted
+            // to work as expected (maintained relative sort-ordering of documents).
+            // All the byte values had 51 added to them except MinValue and MaxValue, as -50 was the lowest value inside of MinValue).
+            // Note: The inconsistent behavior of fields interpreted as byte for sorting purposes could pose a problem for someone
+            // using an index across Lucene and Lucene.NET.
+
+            // tracer  contents         int            float           string   custom   i18n               long            double, 'short', byte
+            new string[] {   "A",   "x a",           "5",           "4f",           "c",     "A-3",   "p\u00EAche",      "10",           "-4" + NDS + "0", "3", "177"/*"126"*/},//A,x
+            new string[] {   "B",   "y a",           "5",           "3" + NDS + "4028235E38", "i",     "B-10",  "HAT",             "1000000000", "40" + NDS + "0", "24", "52"/*"1"*/},//B,y
+            new string[] {   "C",   "x a b c",       "2147483647",  "1" + NDS + "0",          "j",     "A-2",   "p\u00E9ch\u00E9", "99999999",   "40" + NDS + "00002343", "125", "66"/*"15"*/},//C,x
+
+            // {dougsale-2.4.0}
+            // Can't convert from System.Double.MinValue or System.Double.MaxValue to a string and then back to a double
+            // without a System.OverflowException occurring on the way back from string to double - so reduced the
+            // magnitude of the values while maintaining the relative sort orders.  Perhaps we should be using decimal instead
+            // of double...
+
+            new string[] {   "D",   "y a b c",       "-1",          "0" + NDS + "0f",         "a",     "C-0",   "HUT",             System.Int64.MaxValue.ToString(), "-1.77971620351369E+308" /*System.Double.MinValue.ToString()*/, System.Int16.MinValue.ToString(), System.Byte.MinValue.ToString() },//D,y
+            new string[] {   "E",   "x a b c d",     "5",           "2f",           "h",     "B-8",   "peach",           System.Int64.MinValue.ToString(), "1.77971620351369E+308" /*System.Double.MaxValue.ToString()*/, System.Int16.MaxValue.ToString(), System.Byte.MaxValue.ToString() },//E,x
+            new string[] {   "F",   "y a b c d",     "2",           "3" + NDS + "14159f",     "g",     "B-1",   "H\u00C5T",        "-44",           "343" + NDS + "034435444", "-3", "51"/*"0"*/},//F,y
+            new string[] {   "G",   "x a b c d",     "3",           "-1" + NDS + "0",         "f",     "C-100", "sin",             "323254543543", "4" + NDS + "043544", "5", "151"/*"100"*/},//G,x
+            new string[] {   "H",   "y a b c d",     "0",           "1" + NDS + "4E-45",      "e",     "C-88",  "H\u00D8T",        "1023423423005","4" + NDS + "043545", "10", "1"/*"-50"*/},//H,y
+            new string[] {   "I",   "x a b c d e f", "-2147483648", "1" + NDS + "0e+0",       "d",     "A-10",  "s\u00EDn",        "332422459999", "4" + NDS + "043546", "-340", "102"/*"51"*/},//I,x
+            new string[] {   "J",   "y a b c d e f", "4",           "" + NDS + "5",           "b",     "C-7",   "HOT",             "34334543543",  "4" + NDS + "0000220343", "300", "53"/*"2"*/},//J,y
+            new string[] {   "W",   "g",             "1",           null,           null,    null,    null,              null,           null, null, null},
+            new string[] {   "X",   "g",             "1",           "0" + NDS + "1",          null,    null,    null,              null,           null, null, null},
+            new string[] {   "Y",   "g",             "1",           "0" + NDS + "2",          null,    null,    null,              null,           null, null, null},
+            new string[] {   "Z",   "f g",           null,          null,           null,    null,    null,              null,           null, null, null}
+        };
 		
 		// create an index of all the documents, or just the x, or just the y documents
 		private Searcher GetIndex(bool even, bool odd)
 		{
 			RAMDirectory indexStore = new RAMDirectory();
-			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true);
+			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			for (int i = 0; i < data.Length; ++i)
 			{
 				if (((i % 2) == 0 && even) || ((i % 2) == 1 && odd))
 				{
 					Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
 					doc.Add(new Field("tracer", data[i][0], Field.Store.YES, Field.Index.NO));
-					doc.Add(new Field("contents", data[i][1], Field.Store.NO, Field.Index.TOKENIZED));
+					doc.Add(new Field("contents", data[i][1], Field.Store.NO, Field.Index.ANALYZED));
 					if (data[i][2] != null)
-						doc.Add(new Field("int", data[i][2], Field.Store.NO, Field.Index.UN_TOKENIZED));
+						doc.Add(new Field("int", data[i][2], Field.Store.NO, Field.Index.NOT_ANALYZED));
 					if (data[i][3] != null)
-						doc.Add(new Field("float", data[i][3], Field.Store.NO, Field.Index.UN_TOKENIZED));
+						doc.Add(new Field("float", data[i][3], Field.Store.NO, Field.Index.NOT_ANALYZED));
 					if (data[i][4] != null)
-						doc.Add(new Field("string", data[i][4], Field.Store.NO, Field.Index.UN_TOKENIZED));
+						doc.Add(new Field("string", data[i][4], Field.Store.NO, Field.Index.NOT_ANALYZED));
 					if (data[i][5] != null)
-						doc.Add(new Field("custom", data[i][5], Field.Store.NO, Field.Index.UN_TOKENIZED));
+						doc.Add(new Field("custom", data[i][5], Field.Store.NO, Field.Index.NOT_ANALYZED));
 					if (data[i][6] != null)
-						doc.Add(new Field("i18n", data[i][6], Field.Store.NO, Field.Index.UN_TOKENIZED));
+						doc.Add(new Field("i18n", data[i][6], Field.Store.NO, Field.Index.NOT_ANALYZED));
 					if (data[i][7] != null)
-						doc.Add(new Field("long", data[i][7], Field.Store.NO, Field.Index.UN_TOKENIZED));
+						doc.Add(new Field("long", data[i][7], Field.Store.NO, Field.Index.NOT_ANALYZED));
 					if (data[i][8] != null)
-						doc.Add(new Field("double", data[i][8], Field.Store.NO, Field.Index.UN_TOKENIZED));
-					doc.SetBoost(2); // produce some scores above 1.0
+						doc.Add(new Field("double", data[i][8], Field.Store.NO, Field.Index.NOT_ANALYZED));
+                    if (data[i][8] != null)
+                        doc.Add(new Field("short", data[i][9], Field.Store.NO, Field.Index.NOT_ANALYZED));
+                    if (data[i][8] != null)
+                        doc.Add(new Field("byte", data[i][10], Field.Store.NO, Field.Index.NOT_ANALYZED));
+                    doc.SetBoost(2); // produce some scores above 1.0
 					writer.AddDocument(doc);
 				}
 			}
@@ -244,26 +267,34 @@
 		[Test]
 		public virtual void  TestTypedSort()
 		{
-			sort.SetSort(new SortField[]{new SortField("int", SortField.INT), SortField.FIELD_DOC});
-			AssertMatches(full, queryX, sort, "IGAEC");
-			AssertMatches(full, queryY, sort, "DHFJB");
-			
-			sort.SetSort(new SortField[]{new SortField("float", SortField.FLOAT), SortField.FIELD_DOC});
-			AssertMatches(full, queryX, sort, "GCIEA");
-			AssertMatches(full, queryY, sort, "DHJFB");
-			
-			sort.SetSort(new SortField[]{new SortField("string", SortField.STRING), SortField.FIELD_DOC});
-			AssertMatches(full, queryX, sort, "AIGEC");
-			AssertMatches(full, queryY, sort, "DJHFB");
-			
-			sort.SetSort(new SortField[]{new SortField("double", SortField.DOUBLE), SortField.FIELD_DOC});
-			AssertMatches(full, queryX, sort, "AGICE");
-			AssertMatches(full, queryY, sort, "DJHBF");
-			
-			sort.SetSort(new SortField[]{new SortField("string", SortField.STRING), SortField.FIELD_DOC});
-			AssertMatches(full, queryX, sort, "AIGEC");
-			AssertMatches(full, queryY, sort, "DJHFB");
-			}
+            sort.SetSort(new SortField[] { new SortField("int", SortField.INT), SortField.FIELD_DOC });
+            AssertMatches(full, queryX, sort, "IGAEC");
+            AssertMatches(full, queryY, sort, "DHFJB");
+
+            sort.SetSort(new SortField[] { new SortField("float", SortField.FLOAT), SortField.FIELD_DOC });
+            AssertMatches(full, queryX, sort, "GCIEA");
+            AssertMatches(full, queryY, sort, "DHJFB");
+
+            sort.SetSort(new SortField[] { new SortField("string", SortField.STRING), SortField.FIELD_DOC });
+            AssertMatches(full, queryX, sort, "AIGEC");
+            AssertMatches(full, queryY, sort, "DJHFB");
+
+            sort.SetSort(new SortField[] { new SortField("double", SortField.DOUBLE), SortField.FIELD_DOC });
+            AssertMatches(full, queryX, sort, "AGICE");
+            AssertMatches(full, queryY, sort, "DJHBF");
+
+            sort.SetSort(new SortField[] { new SortField("byte", SortField.BYTE), SortField.FIELD_DOC });
+            AssertMatches(full, queryX, sort, "CIGAE");
+            AssertMatches(full, queryY, sort, "DHFBJ");
+
+            sort.SetSort(new SortField[] { new SortField("short", SortField.SHORT), SortField.FIELD_DOC });
+            AssertMatches(full, queryX, sort, "IAGCE");
+            AssertMatches(full, queryY, sort, "DFHBJ");
+
+            sort.SetSort(new SortField[] { new SortField("string", SortField.STRING), SortField.FIELD_DOC });
+            AssertMatches(full, queryX, sort, "AIGEC");
+            AssertMatches(full, queryY, sort, "DJHFB");
+        }
 		
 		// test sorts when there's nothing in the index
 		[Test]
@@ -520,9 +551,9 @@
 		{
 			
 			// capture relevancy scores
-			System.Collections.Hashtable scoresX = GetScores(full.Search(queryX));
-			System.Collections.Hashtable scoresY = GetScores(full.Search(queryY));
-			System.Collections.Hashtable scoresA = GetScores(full.Search(queryA));
+            System.Collections.Hashtable scoresX = GetScores(full.Search(queryX, null, 1000).scoreDocs, full);
+            System.Collections.Hashtable scoresY = GetScores(full.Search(queryY, null, 1000).scoreDocs, full);
+            System.Collections.Hashtable scoresA = GetScores(full.Search(queryA, null, 1000).scoreDocs, full);
 			
 			// we'll test searching locally, remote and multi
 			MultiSearcher remote = new MultiSearcher(new Lucene.Net.Search.Searchable[]{GetRemote()});
@@ -531,92 +562,92 @@
 			// change sorting and make sure relevancy stays the same
 			
 			sort = new Sort();
-			AssertSameValues(scoresX, GetScores(full.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(remote.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(multi.Search(queryX, sort)));
-			AssertSameValues(scoresY, GetScores(full.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(remote.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(multi.Search(queryY, sort)));
-			AssertSameValues(scoresA, GetScores(full.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(remote.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(multi.Search(queryA, sort)));
+			AssertSameValues(scoresX, GetScores(full.Search(queryX, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresX, GetScores(remote.Search(queryX, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresX, GetScores(multi.Search(queryX, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresY, GetScores(full.Search(queryY, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresY, GetScores(remote.Search(queryY, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresY, GetScores(multi.Search(queryY, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresA, GetScores(full.Search(queryA, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresA, GetScores(remote.Search(queryA, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresA, GetScores(multi.Search(queryA, null, 1000, sort).scoreDocs, multi));
 			
 			sort.SetSort(SortField.FIELD_DOC);
-			AssertSameValues(scoresX, GetScores(full.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(remote.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(multi.Search(queryX, sort)));
-			AssertSameValues(scoresY, GetScores(full.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(remote.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(multi.Search(queryY, sort)));
-			AssertSameValues(scoresA, GetScores(full.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(remote.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(multi.Search(queryA, sort)));
+			AssertSameValues(scoresX, GetScores(full.Search(queryX, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresX, GetScores(remote.Search(queryX, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresX, GetScores(multi.Search(queryX, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresY, GetScores(full.Search(queryY, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresY, GetScores(remote.Search(queryY, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresY, GetScores(multi.Search(queryY, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresA, GetScores(full.Search(queryA, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresA, GetScores(remote.Search(queryA, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresA, GetScores(multi.Search(queryA, null, 1000, sort).scoreDocs, multi));
 			
 			sort.SetSort("int");
-			AssertSameValues(scoresX, GetScores(full.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(remote.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(multi.Search(queryX, sort)));
-			AssertSameValues(scoresY, GetScores(full.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(remote.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(multi.Search(queryY, sort)));
-			AssertSameValues(scoresA, GetScores(full.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(remote.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(multi.Search(queryA, sort)));
+			AssertSameValues(scoresX, GetScores(full.Search(queryX, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresX, GetScores(remote.Search(queryX, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresX, GetScores(multi.Search(queryX, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresY, GetScores(full.Search(queryY, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresY, GetScores(remote.Search(queryY, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresY, GetScores(multi.Search(queryY, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresA, GetScores(full.Search(queryA, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresA, GetScores(remote.Search(queryA, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresA, GetScores(multi.Search(queryA, null, 1000, sort).scoreDocs, multi));
 			
 			sort.SetSort("float");
-			AssertSameValues(scoresX, GetScores(full.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(remote.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(multi.Search(queryX, sort)));
-			AssertSameValues(scoresY, GetScores(full.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(remote.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(multi.Search(queryY, sort)));
-			AssertSameValues(scoresA, GetScores(full.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(remote.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(multi.Search(queryA, sort)));
+			AssertSameValues(scoresX, GetScores(full.Search(queryX, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresX, GetScores(remote.Search(queryX, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresX, GetScores(multi.Search(queryX, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresY, GetScores(full.Search(queryY, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresY, GetScores(remote.Search(queryY, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresY, GetScores(multi.Search(queryY, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresA, GetScores(full.Search(queryA, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresA, GetScores(remote.Search(queryA, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresA, GetScores(multi.Search(queryA, null, 1000, sort).scoreDocs, multi));
 			
 			sort.SetSort("string");
-			AssertSameValues(scoresX, GetScores(full.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(remote.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(multi.Search(queryX, sort)));
-			AssertSameValues(scoresY, GetScores(full.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(remote.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(multi.Search(queryY, sort)));
-			AssertSameValues(scoresA, GetScores(full.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(remote.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(multi.Search(queryA, sort)));
+			AssertSameValues(scoresX, GetScores(full.Search(queryX, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresX, GetScores(remote.Search(queryX, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresX, GetScores(multi.Search(queryX, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresY, GetScores(full.Search(queryY, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresY, GetScores(remote.Search(queryY, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresY, GetScores(multi.Search(queryY, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresA, GetScores(full.Search(queryA, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresA, GetScores(remote.Search(queryA, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresA, GetScores(multi.Search(queryA, null, 1000, sort).scoreDocs, multi));
 			
 			sort.SetSort(new System.String[]{"int", "float"});
-			AssertSameValues(scoresX, GetScores(full.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(remote.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(multi.Search(queryX, sort)));
-			AssertSameValues(scoresY, GetScores(full.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(remote.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(multi.Search(queryY, sort)));
-			AssertSameValues(scoresA, GetScores(full.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(remote.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(multi.Search(queryA, sort)));
+			AssertSameValues(scoresX, GetScores(full.Search(queryX, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresX, GetScores(remote.Search(queryX, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresX, GetScores(multi.Search(queryX, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresY, GetScores(full.Search(queryY, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresY, GetScores(remote.Search(queryY, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresY, GetScores(multi.Search(queryY, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresA, GetScores(full.Search(queryA, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresA, GetScores(remote.Search(queryA, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresA, GetScores(multi.Search(queryA, null, 1000, sort).scoreDocs, multi));
 			
 			sort.SetSort(new SortField[]{new SortField("int", true), new SortField(null, SortField.DOC, true)});
-			AssertSameValues(scoresX, GetScores(full.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(remote.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(multi.Search(queryX, sort)));
-			AssertSameValues(scoresY, GetScores(full.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(remote.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(multi.Search(queryY, sort)));
-			AssertSameValues(scoresA, GetScores(full.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(remote.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(multi.Search(queryA, sort)));
+			AssertSameValues(scoresX, GetScores(full.Search(queryX, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresX, GetScores(remote.Search(queryX, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresX, GetScores(multi.Search(queryX, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresY, GetScores(full.Search(queryY, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresY, GetScores(remote.Search(queryY, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresY, GetScores(multi.Search(queryY, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresA, GetScores(full.Search(queryA, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresA, GetScores(remote.Search(queryA, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresA, GetScores(multi.Search(queryA, null, 1000, sort).scoreDocs, multi));
 			
 			sort.SetSort(new System.String[]{"float", "string"});
-			AssertSameValues(scoresX, GetScores(full.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(remote.Search(queryX, sort)));
-			AssertSameValues(scoresX, GetScores(multi.Search(queryX, sort)));
-			AssertSameValues(scoresY, GetScores(full.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(remote.Search(queryY, sort)));
-			AssertSameValues(scoresY, GetScores(multi.Search(queryY, sort)));
-			AssertSameValues(scoresA, GetScores(full.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(remote.Search(queryA, sort)));
-			AssertSameValues(scoresA, GetScores(multi.Search(queryA, sort)));
+			AssertSameValues(scoresX, GetScores(full.Search(queryX, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresX, GetScores(remote.Search(queryX, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresX, GetScores(multi.Search(queryX, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresY, GetScores(full.Search(queryY, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresY, GetScores(remote.Search(queryY, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresY, GetScores(multi.Search(queryY, null, 1000, sort).scoreDocs, multi));
+			AssertSameValues(scoresA, GetScores(full.Search(queryA, null, 1000, sort).scoreDocs, full));
+			AssertSameValues(scoresA, GetScores(remote.Search(queryA, null, 1000, sort).scoreDocs, remote));
+			AssertSameValues(scoresA, GetScores(multi.Search(queryA, null, 1000, sort).scoreDocs, multi));
 		}
 		
 		[Test]
@@ -705,12 +736,12 @@
 		// make sure the documents returned by the search match the expected list
 		private void  AssertMatches(Searcher searcher, Query query, Sort sort, System.String expectedResult)
 		{
-			Hits result = searcher.Search(query, sort);
+			ScoreDoc[] result = searcher.Search(query, null, 1000, sort).scoreDocs;
 			System.Text.StringBuilder buff = new System.Text.StringBuilder(10);
-			int n = result.Length();
+			int n = result.Length;
 			for (int i = 0; i < n; ++i)
 			{
-				Lucene.Net.Documents.Document doc = result.Doc(i);
+				Lucene.Net.Documents.Document doc = searcher.Doc(result[i].doc);
 				System.String[] v = doc.GetValues("tracer");
 				for (int j = 0; j < v.Length; ++j)
 				{
@@ -723,12 +754,12 @@
 		// make sure the documents returned by the search match the expected list pattern
 		private void  AssertMatchesPattern(Searcher searcher, Query query, Sort sort, System.String pattern)
 		{
-			Hits result = searcher.Search(query, sort);
+			ScoreDoc[] result = searcher.Search(query, null, 1000, sort).scoreDocs;
 			System.Text.StringBuilder buff = new System.Text.StringBuilder(10);
-			int n = result.Length();
+			int n = result.Length;
 			for (int i = 0; i < n; ++i)
 			{
-				Lucene.Net.Documents.Document doc = result.Doc(i);
+				Lucene.Net.Documents.Document doc = searcher.Doc(result[i].doc);
 				System.String[] v = doc.GetValues("tracer");
 				for (int j = 0; j < v.Length; ++j)
 				{
@@ -740,16 +771,16 @@
 			Assert.IsTrue(p.Match(buff.ToString()).Success);
 		}
 		
-		private System.Collections.Hashtable GetScores(Hits hits)
+		private System.Collections.Hashtable GetScores(ScoreDoc[] hits, Searcher searcher)
 		{
 			System.Collections.Hashtable scoreMap = new System.Collections.Hashtable();
-			int n = hits.Length();
+			int n = hits.Length;
 			for (int i = 0; i < n; ++i)
 			{
-				Lucene.Net.Documents.Document doc = hits.Doc(i);
+				Lucene.Net.Documents.Document doc = searcher.Doc(hits[i].doc);
 				System.String[] v = doc.GetValues("tracer");
 				Assert.AreEqual(v.Length, 1);
-				scoreMap[v[0]] = (float) hits.Score(i);
+                scoreMap[v[0]] = (float)hits[i].score;
 			}
 			return scoreMap;
 		}



Mime
View raw message