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 2009/11/03 19:06:38 UTC

svn commit: r832486 [21/29] - in /incubator/lucene.net/trunk/C#/src: ./ Demo/DeleteFiles/ Demo/DemoLib/ Demo/IndexFiles/ Demo/IndexHtml/ Demo/SearchFiles/ Lucene.Net/ Lucene.Net/Analysis/ Lucene.Net/Document/ Lucene.Net/Index/ Lucene.Net/Search/ Lucene...

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestMultiSearcher.cs?rev=832486&r1=832485&r2=832486&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiSearcher.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiSearcher.cs Tue Nov  3 18:06:27 2009
@@ -1,4 +1,4 @@
-/*
+/* 
  * 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.
@@ -19,6 +19,8 @@
 
 using NUnit.Framework;
 
+using KeywordAnalyzer = Lucene.Net.Analysis.KeywordAnalyzer;
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
 using Document = Lucene.Net.Documents.Document;
 using Field = Lucene.Net.Documents.Field;
 using SetBasedFieldSelector = Lucene.Net.Documents.SetBasedFieldSelector;
@@ -29,8 +31,6 @@
 using Directory = Lucene.Net.Store.Directory;
 using MockRAMDirectory = Lucene.Net.Store.MockRAMDirectory;
 using RAMDirectory = Lucene.Net.Store.RAMDirectory;
-using KeywordAnalyzer = Lucene.Net.Analysis.KeywordAnalyzer;
-using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
 using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
 
 namespace Lucene.Net.Search
@@ -39,13 +39,13 @@
 	/// <summary> Tests {@link MultiSearcher} class.
 	/// 
 	/// </summary>
-	/// <version>  $Id: TestMultiSearcher.java 583534 2007-10-10 16:46:35Z mikemccand $
+	/// <version>  $Id: TestMultiSearcher.java 781130 2009-06-02 19:16:20Z mikemccand $
 	/// </version>
-	[TestFixture]
-	public class TestMultiSearcher : LuceneTestCase
+    [TestFixture]
+	public class TestMultiSearcher:LuceneTestCase
 	{
 		[Serializable]
-		private class AnonymousClassDefaultSimilarity : DefaultSimilarity
+		private class AnonymousClassDefaultSimilarity:DefaultSimilarity
 		{
 			public AnonymousClassDefaultSimilarity(TestMultiSearcher enclosingInstance)
 			{
@@ -90,8 +90,7 @@
 				return 1.0f;
 			}
 		}
-
-		public TestMultiSearcher() : base()
+		public TestMultiSearcher(System.String name):base(name)
 		{
 		}
 		
@@ -131,7 +130,7 @@
 			// creating an index writer for the first index
 			IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			// creating an index writer for the second index, but writing nothing
-            IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+			IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			
 			//--------------------------------------------------------------------
 			// scenario 1
@@ -148,7 +147,7 @@
 			writerB.Close();
 			
 			// creating the query
-			Lucene.Net.QueryParsers.QueryParser parser = new Lucene.Net.QueryParsers.QueryParser("fulltext", new StandardAnalyzer());
+			QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer());
 			Query query = parser.Parse("handle:1");
 			
 			// building the searchables
@@ -166,7 +165,7 @@
 			// iterating over the hit documents
 			for (int i = 0; i < hits.Length; i++)
 			{
-				Document d = mSearcher.Doc(hits[i].doc);
+				mSearcher.Doc(hits[i].doc);
 			}
 			mSearcher.Close();
 			
@@ -197,17 +196,17 @@
 			for (int i = 0; i < hits2.Length; i++)
 			{
 				// no exception should happen at this point
-                Document d = mSearcher2.Doc(hits2[i].doc);
+				mSearcher2.Doc(hits2[i].doc);
 			}
 			
 			// test the subSearcher() method:
 			Query subSearcherQuery = parser.Parse("id:doc1");
-            hits2 = mSearcher2.Search(subSearcherQuery, null, 1000).scoreDocs;
+			hits2 = mSearcher2.Search(subSearcherQuery, null, 1000).scoreDocs;
 			Assert.AreEqual(2, hits2.Length);
 			Assert.AreEqual(0, mSearcher2.SubSearcher(hits2[0].doc)); // hit from searchers2[0]
 			Assert.AreEqual(1, mSearcher2.SubSearcher(hits2[1].doc)); // hit from searchers2[1]
 			subSearcherQuery = parser.Parse("id:doc2");
-            hits2 = mSearcher2.Search(subSearcherQuery, null, 1000).scoreDocs;
+			hits2 = mSearcher2.Search(subSearcherQuery, null, 1000).scoreDocs;
 			Assert.AreEqual(1, hits2.Length);
 			Assert.AreEqual(1, mSearcher2.SubSearcher(hits2[0].doc)); // hit from searchers2[1]
 			mSearcher2.Close();
@@ -223,7 +222,7 @@
 			readerB.Close();
 			
 			// optimizing the index with the writer
-            writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+			writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
 			writerB.Optimize();
 			writerB.Close();
 			
@@ -235,21 +234,21 @@
 			// creating the mulitSearcher
 			Searcher mSearcher3 = GetMultiSearcherInstance(searchers3);
 			// performing the same search
-            ScoreDoc[] hits3 = mSearcher3.Search(query, null, 1000).scoreDocs;
+			ScoreDoc[] hits3 = mSearcher3.Search(query, null, 1000).scoreDocs;
 			
 			Assert.AreEqual(3, hits3.Length);
 			
 			// iterating over the hit documents
 			for (int i = 0; i < hits3.Length; i++)
 			{
-                Document d = mSearcher3.Doc(hits3[i].doc);
+				mSearcher3.Doc(hits3[i].doc);
 			}
 			mSearcher3.Close();
 			indexStoreA.Close();
 			indexStoreB.Close();
 		}
 		
-		private static Document DreateDocument(System.String contents1, System.String contents2)
+		private static Document CreateDocument(System.String contents1, System.String contents2)
 		{
 			Document document = new Document();
 			
@@ -269,11 +268,11 @@
 			
 			try
 			{
-                indexWriter = new IndexWriter(directory, new KeywordAnalyzer(), create, IndexWriter.MaxFieldLength.LIMITED);
+				indexWriter = new IndexWriter(directory, new KeywordAnalyzer(), create, IndexWriter.MaxFieldLength.LIMITED);
 				
 				for (int i = 0; i < nDocs; i++)
 				{
-					indexWriter.AddDocument(DreateDocument("doc" + i, contents2));
+					indexWriter.AddDocument(CreateDocument("doc" + i, contents2));
 				}
 			}
 			finally
@@ -304,7 +303,7 @@
 			
 			MultiSearcher searcher = GetMultiSearcherInstance(new Searcher[]{indexSearcher1, indexSearcher2});
 			Assert.IsTrue(searcher != null, "searcher is null and it shouldn't be");
-            ScoreDoc[] hits = searcher.Search(query, null, 1000).scoreDocs;
+			ScoreDoc[] hits = searcher.Search(query, null, 1000).scoreDocs;
 			Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
 			Assert.IsTrue(hits.Length == 2, hits.Length + " does not equal: " + 2);
 			Document document = searcher.Doc(hits[0].doc);
@@ -313,8 +312,8 @@
 			//Should be one document from each directory
 			//they both have two fields, contents and other
 			System.Collections.Hashtable ftl = new System.Collections.Hashtable();
-			ftl.Add("other", "other");
-			SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, new System.Collections.Hashtable());
+			SupportClass.CollectionsHelper.AddIfNotContains(ftl, "other");
+			SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, (System.Collections.Hashtable) new System.Collections.Hashtable());
 			document = searcher.Doc(hits[0].doc, fs);
 			Assert.IsTrue(document != null, "document is null and it shouldn't be");
 			Assert.IsTrue(document.GetFields().Count == 1, "document.getFields() Size: " + document.GetFields().Count + " is not: " + 1);
@@ -323,8 +322,8 @@
 			value_Renamed = document.Get("other");
 			Assert.IsTrue(value_Renamed != null, "value is null and it shouldn't be");
 			ftl.Clear();
-			ftl.Add("contents", "contents");
-			fs = new SetBasedFieldSelector(ftl, new System.Collections.Hashtable());
+			SupportClass.CollectionsHelper.AddIfNotContains(ftl, "contents");
+			fs = new SetBasedFieldSelector(ftl, (System.Collections.Hashtable) new System.Collections.Hashtable());
 			document = searcher.Doc(hits[1].doc, fs);
 			value_Renamed = document.Get("contents");
 			Assert.IsTrue(value_Renamed != null, "value is null and it shouldn't be");
@@ -359,8 +358,9 @@
 			InitIndex(ramDirectory1, nDocs, false, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
 			
 			indexSearcher1 = new IndexSearcher(ramDirectory1);
-
-            hits = indexSearcher1.Search(query, null, 1000).scoreDocs;
+			indexSearcher1.SetDefaultFieldSortScoring(true, true);
+			
+			hits = indexSearcher1.Search(query, null, 1000).scoreDocs;
 			
 			Assert.AreEqual(2, hits.Length, message);
 			
@@ -386,11 +386,13 @@
 			InitIndex(ramDirectory2, nDocs, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
 			
 			indexSearcher1 = new IndexSearcher(ramDirectory1);
+			indexSearcher1.SetDefaultFieldSortScoring(true, true);
 			indexSearcher2 = new IndexSearcher(ramDirectory2);
+			indexSearcher2.SetDefaultFieldSortScoring(true, true);
 			
 			Searcher searcher = GetMultiSearcherInstance(new Searcher[]{indexSearcher1, indexSearcher2});
-
-            hits = searcher.Search(query, null, 1000).scoreDocs;
+			
+			hits = searcher.Search(query, null, 1000).scoreDocs;
 			
 			Assert.AreEqual(2, hits.Length, message);
 			
@@ -401,7 +403,7 @@
 			
 			
 			// Adding a Sort.RELEVANCE object should not change anything
-            hits = searcher.Search(query, null, 1000, Sort.RELEVANCE).scoreDocs;
+			hits = searcher.Search(query, null, 1000, Sort.RELEVANCE).scoreDocs;
 			
 			Assert.AreEqual(2, hits.Length, message);
 			

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiSearcherRanking.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestMultiSearcherRanking.cs?rev=832486&r1=832485&r2=832486&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiSearcherRanking.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiSearcherRanking.cs Tue Nov  3 18:06:27 2009
@@ -1,4 +1,4 @@
-/*
+/* 
  * 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.
@@ -19,6 +19,7 @@
 
 using NUnit.Framework;
 
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
 using Document = Lucene.Net.Documents.Document;
 using Field = Lucene.Net.Documents.Field;
 using IndexWriter = Lucene.Net.Index.IndexWriter;
@@ -26,7 +27,6 @@
 using QueryParser = Lucene.Net.QueryParsers.QueryParser;
 using Directory = Lucene.Net.Store.Directory;
 using RAMDirectory = Lucene.Net.Store.RAMDirectory;
-using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
 using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
 
 namespace Lucene.Net.Search
@@ -38,8 +38,8 @@
 	/// </summary>
 	/// <version>  $Id: TestMultiSearcher.java 150492 2004-09-06 22:01:49Z dnaber $
 	/// </version>
-	[TestFixture]
-	public class TestMultiSearcherRanking : LuceneTestCase
+    [TestFixture]
+	public class TestMultiSearcherRanking:LuceneTestCase
 	{
 		
 		private bool verbose = false; // set to true to output hits
@@ -109,15 +109,15 @@
 			// check result hit ranking
 			if (verbose)
 				System.Console.Out.WriteLine("Query: " + queryStr);
-			Lucene.Net.QueryParsers.QueryParser queryParser = new Lucene.Net.QueryParsers.QueryParser(FIELD_NAME, new StandardAnalyzer());
-			Lucene.Net.Search.Query query = queryParser.Parse(queryStr);
+			QueryParser queryParser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+			Query query = queryParser.Parse(queryStr);
 			ScoreDoc[] multiSearcherHits = multiSearcher.Search(query, null, 1000).scoreDocs;
-            ScoreDoc[] singleSearcherHits = singleSearcher.Search(query, null, 1000).scoreDocs;
+			ScoreDoc[] singleSearcherHits = singleSearcher.Search(query, null, 1000).scoreDocs;
 			Assert.AreEqual(multiSearcherHits.Length, singleSearcherHits.Length);
 			for (int i = 0; i < multiSearcherHits.Length; i++)
 			{
-                Lucene.Net.Documents.Document docMulti = multiSearcher.Doc(multiSearcherHits[i].doc);
-				Lucene.Net.Documents.Document docSingle = singleSearcher.Doc(singleSearcherHits[i].doc);
+				Document docMulti = multiSearcher.Doc(multiSearcherHits[i].doc);
+				Document docSingle = singleSearcher.Doc(singleSearcherHits[i].doc);
 				if (verbose)
 					System.Console.Out.WriteLine("Multi:  " + docMulti.Get(FIELD_NAME) + " score=" + multiSearcherHits[i].score);
 				if (verbose)
@@ -130,8 +130,8 @@
 		}
 		
 		/// <summary> initializes multiSearcher and singleSearcher with the same document set</summary>
-		[SetUp]
-		public override void SetUp()
+		[Test]
+		public override void  SetUp()
 		{
 			base.SetUp();
 			// create MultiSearcher from two seperate searchers
@@ -140,18 +140,18 @@
 			AddCollection1(iw1);
 			iw1.Close();
 			Directory d2 = new RAMDirectory();
-            IndexWriter iw2 = new IndexWriter(d2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+			IndexWriter iw2 = new IndexWriter(d2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			AddCollection2(iw2);
 			iw2.Close();
 			
-			Lucene.Net.Search.Searchable[] s = new Lucene.Net.Search.Searchable[2];
+			Searchable[] s = new Searchable[2];
 			s[0] = new IndexSearcher(d1);
 			s[1] = new IndexSearcher(d2);
 			multiSearcher = new MultiSearcher(s);
 			
 			// create IndexSearcher which contains all documents
 			Directory d = new RAMDirectory();
-            IndexWriter iw = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+			IndexWriter iw = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			AddCollection1(iw);
 			AddCollection2(iw);
 			iw.Close();
@@ -181,7 +181,7 @@
 		
 		private void  Add(System.String value_Renamed, IndexWriter iw)
 		{
-			Lucene.Net.Documents.Document d = new Lucene.Net.Documents.Document();
+			Document d = new Document();
 			d.Add(new Field(FIELD_NAME, value_Renamed, Field.Store.YES, Field.Index.ANALYZED));
 			iw.AddDocument(d);
 		}

Added: incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiTermConstantScore.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestMultiTermConstantScore.cs?rev=832486&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiTermConstantScore.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiTermConstantScore.cs Tue Nov  3 18:06:27 2009
@@ -0,0 +1,720 @@
+/* 
+ * 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 System;
+
+using NUnit.Framework;
+
+using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+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 Directory = Lucene.Net.Store.Directory;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+
+namespace Lucene.Net.Search
+{
+	
+    [TestFixture]
+	public class TestMultiTermConstantScore:BaseTestRangeFilter
+	{
+		private class AnonymousClassCollector:Collector
+		{
+			public AnonymousClassCollector(TestMultiTermConstantScore enclosingInstance)
+			{
+				InitBlock(enclosingInstance);
+			}
+			private void  InitBlock(TestMultiTermConstantScore enclosingInstance)
+			{
+				this.enclosingInstance = enclosingInstance;
+			}
+			private TestMultiTermConstantScore enclosingInstance;
+			public TestMultiTermConstantScore Enclosing_Instance
+			{
+				get
+				{
+					return enclosingInstance;
+				}
+				
+			}
+			private int base_Renamed = 0;
+			private Scorer scorer;
+			public override void  SetScorer(Scorer scorer)
+			{
+				this.scorer = scorer;
+			}
+			public override void  Collect(int doc)
+			{
+				Enclosing_Instance.AssertEquals("score for doc " + (doc + base_Renamed) + " was not correct", 1.0f, scorer.Score());
+			}
+			public override void  SetNextReader(IndexReader reader, int docBase)
+			{
+				base_Renamed = docBase;
+			}
+			public override bool AcceptsDocsOutOfOrder()
+			{
+				return true;
+			}
+		}
+		
+		/// <summary>threshold for comparing floats </summary>
+		public const float SCORE_COMP_THRESH = 1e-6f;
+		
+		public TestMultiTermConstantScore(System.String name):base(name)
+		{
+		}
+		
+		public TestMultiTermConstantScore():base()
+		{
+		}
+		
+		internal Directory small;
+		
+		internal virtual void  AssertEquals(System.String m, float e, float a)
+		{
+			Assert.AreEqual(e, a, SCORE_COMP_THRESH, m);
+		}
+		
+		static public void  AssertEquals(System.String m, int e, int a)
+		{
+			Assert.AreEqual(e, a, m);
+		}
+		
+		[Test]
+		public override void  SetUp()
+		{
+			base.SetUp();
+			
+			System.String[] data = new System.String[]{"A 1 2 3 4 5 6", "Z       4 5 6", null, "B   2   4 5 6", "Y     3   5 6", null, "C     3     6", "X       4 5 6"};
+			
+			small = new RAMDirectory();
+			IndexWriter writer = new IndexWriter(small, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+			
+			for (int i = 0; i < data.Length; i++)
+			{
+				Document doc = new Document();
+				doc.Add(new Field("id", System.Convert.ToString(i), Field.Store.YES, Field.Index.NOT_ANALYZED)); // Field.Keyword("id",String.valueOf(i)));
+				doc.Add(new Field("all", "all", Field.Store.YES, Field.Index.NOT_ANALYZED)); // Field.Keyword("all","all"));
+				if (null != data[i])
+				{
+					doc.Add(new Field("data", data[i], Field.Store.YES, Field.Index.ANALYZED)); // Field.Text("data",data[i]));
+				}
+				writer.AddDocument(doc);
+			}
+			
+			writer.Optimize();
+			writer.Close();
+		}
+		
+		/// <summary>macro for readability </summary>
+		public static Query Csrq(System.String f, System.String l, System.String h, bool il, bool ih)
+		{
+			TermRangeQuery query = new TermRangeQuery(f, l, h, il, ih);
+			query.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
+			return query;
+		}
+		
+		public static Query Csrq(System.String f, System.String l, System.String h, bool il, bool ih, MultiTermQuery.RewriteMethod method)
+		{
+			TermRangeQuery query = new TermRangeQuery(f, l, h, il, ih);
+			query.SetRewriteMethod(method);
+			return query;
+		}
+		
+		/// <summary>macro for readability </summary>
+		public static Query Csrq(System.String f, System.String l, System.String h, bool il, bool ih, System.Globalization.CompareInfo c)
+		{
+			TermRangeQuery query = new TermRangeQuery(f, l, h, il, ih, c);
+			query.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
+			return query;
+		}
+		
+		/// <summary>macro for readability </summary>
+		public static Query Cspq(Term prefix)
+		{
+			PrefixQuery query = new PrefixQuery(prefix);
+			query.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
+			return query;
+		}
+		
+		/// <summary>macro for readability </summary>
+		public static Query Cswcq(Term wild)
+		{
+			WildcardQuery query = new WildcardQuery(wild);
+			query.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
+			return query;
+		}
+		
+        [Test]
+		public virtual void  TestBasics()
+		{
+			QueryUtils.Check(Csrq("data", "1", "6", T, T));
+			QueryUtils.Check(Csrq("data", "A", "Z", T, T));
+			QueryUtils.CheckUnequal(Csrq("data", "1", "6", T, T), Csrq("data", "A", "Z", T, T));
+			
+			QueryUtils.Check(Cspq(new Term("data", "p*u?")));
+			QueryUtils.CheckUnequal(Cspq(new Term("data", "pre*")), Cspq(new Term("data", "pres*")));
+			
+			QueryUtils.Check(Cswcq(new Term("data", "p")));
+			QueryUtils.CheckUnequal(Cswcq(new Term("data", "pre*n?t")), Cswcq(new Term("data", "pr*t?j")));
+		}
+		
+        [Test]
+		public virtual void  TestBasicsRngCollating()
+		{
+			System.Globalization.CompareInfo c = new System.Globalization.CultureInfo("en").CompareInfo;
+			QueryUtils.Check(Csrq("data", "1", "6", T, T, c));
+			QueryUtils.Check(Csrq("data", "A", "Z", T, T, c));
+			QueryUtils.CheckUnequal(Csrq("data", "1", "6", T, T, c), Csrq("data", "A", "Z", T, T, c));
+		}
+		
+        [Test]
+		public virtual void  TestEqualScores()
+		{
+			// NOTE: uses index build in *this* setUp
+			
+			IndexReader reader = IndexReader.Open(small);
+			IndexSearcher search = new IndexSearcher(reader);
+			
+			ScoreDoc[] result;
+			
+			// some hits match more terms then others, score should be the same
+			
+			result = search.Search(Csrq("data", "1", "6", T, T), null, 1000).scoreDocs;
+			int numHits = result.Length;
+			AssertEquals("wrong number of results", 6, numHits);
+			float score = result[0].score;
+			for (int i = 1; i < numHits; i++)
+			{
+				AssertEquals("score for " + i + " was not the same", score, result[i].score);
+			}
+			
+			result = search.Search(Csrq("data", "1", "6", T, T, MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE), null, 1000).scoreDocs;
+			numHits = result.Length;
+			AssertEquals("wrong number of results", 6, numHits);
+			for (int i = 0; i < numHits; i++)
+			{
+				AssertEquals("score for " + i + " was not the same", score, result[i].score);
+			}
+		}
+		
+        [Test]
+		public virtual void  TestBoost()
+		{
+			// NOTE: uses index build in *this* setUp
+			
+			IndexReader reader = IndexReader.Open(small);
+			IndexSearcher search = new IndexSearcher(reader);
+			
+			// test for correct application of query normalization
+			// must use a non score normalizing method for this.
+			Query q = Csrq("data", "1", "6", T, T);
+			q.SetBoost(100);
+			search.Search(q, null, new AnonymousClassCollector(this));
+			
+			//
+			// Ensure that boosting works to score one clause of a query higher
+			// than another.
+			//
+			Query q1 = Csrq("data", "A", "A", T, T); // matches document #0
+			q1.SetBoost(.1f);
+			Query q2 = Csrq("data", "Z", "Z", T, T); // matches document #1
+			BooleanQuery bq = new BooleanQuery(true);
+			bq.Add(q1, BooleanClause.Occur.SHOULD);
+			bq.Add(q2, BooleanClause.Occur.SHOULD);
+			
+			ScoreDoc[] hits = search.Search(bq, null, 1000).scoreDocs;
+			Assert.AreEqual(1, hits[0].doc);
+			Assert.AreEqual(0, hits[1].doc);
+			Assert.IsTrue(hits[0].score > hits[1].score);
+			
+			q1 = Csrq("data", "A", "A", T, T, MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE); // matches document #0
+			q1.SetBoost(.1f);
+			q2 = Csrq("data", "Z", "Z", T, T, MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE); // matches document #1
+			bq = new BooleanQuery(true);
+			bq.Add(q1, BooleanClause.Occur.SHOULD);
+			bq.Add(q2, BooleanClause.Occur.SHOULD);
+			
+			hits = search.Search(bq, null, 1000).scoreDocs;
+			Assert.AreEqual(1, hits[0].doc);
+			Assert.AreEqual(0, hits[1].doc);
+			Assert.IsTrue(hits[0].score > hits[1].score);
+			
+			q1 = Csrq("data", "A", "A", T, T); // matches document #0
+			q1.SetBoost(10f);
+			q2 = Csrq("data", "Z", "Z", T, T); // matches document #1
+			bq = new BooleanQuery(true);
+			bq.Add(q1, BooleanClause.Occur.SHOULD);
+			bq.Add(q2, BooleanClause.Occur.SHOULD);
+			
+			hits = search.Search(bq, null, 1000).scoreDocs;
+			Assert.AreEqual(0, hits[0].doc);
+			Assert.AreEqual(1, hits[1].doc);
+			Assert.IsTrue(hits[0].score > hits[1].score);
+		}
+		
+        [Test]
+		public virtual void  TestBooleanOrderUnAffected()
+		{
+			// NOTE: uses index build in *this* setUp
+			
+			IndexReader reader = IndexReader.Open(small);
+			IndexSearcher search = new IndexSearcher(reader);
+			
+			// first do a regular TermRangeQuery which uses term expansion so
+			// docs with more terms in range get higher scores
+			
+			Query rq = new TermRangeQuery("data", "1", "4", T, T);
+			
+			ScoreDoc[] expected = search.Search(rq, null, 1000).scoreDocs;
+			int numHits = expected.Length;
+			
+			// now do a boolean where which also contains a
+			// ConstantScoreRangeQuery and make sure hte order is the same
+			
+			BooleanQuery q = new BooleanQuery();
+			q.Add(rq, BooleanClause.Occur.MUST); // T, F);
+			q.Add(Csrq("data", "1", "6", T, T), BooleanClause.Occur.MUST); // T, F);
+			
+			ScoreDoc[] actual = search.Search(q, null, 1000).scoreDocs;
+			
+			AssertEquals("wrong numebr of hits", numHits, actual.Length);
+			for (int i = 0; i < numHits; i++)
+			{
+				AssertEquals("mismatch in docid for hit#" + i, expected[i].doc, actual[i].doc);
+			}
+		}
+		
+        [Test]
+		public virtual void  TestRangeQueryId()
+		{
+			// NOTE: uses index build in *super* setUp
+			
+			IndexReader reader = IndexReader.Open(signedIndex.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();
+			
+			AssertEquals("num of docs", numDocs, 1 + maxId - minId);
+			
+			ScoreDoc[] result;
+			
+			// test id, bounded on both ends
+			
+			result = search.Search(Csrq("id", minIP, maxIP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("find all", numDocs, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("find all", numDocs, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, T, F), null, numDocs).scoreDocs;
+			AssertEquals("all but last", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, T, F, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("all but last", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, F, T), null, numDocs).scoreDocs;
+			AssertEquals("all but first", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, F, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("all but first", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("all but ends", numDocs - 2, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, F, F, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("all but ends", numDocs - 2, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, maxIP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("med and up", 1 + maxId - medId, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, maxIP, T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("med and up", 1 + maxId - medId, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, medIP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("up to med", 1 + medId - minId, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, medIP, T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("up to med", 1 + medId - minId, result.Length);
+			
+			// unbounded id
+			
+			result = search.Search(Csrq("id", minIP, null, T, F), null, numDocs).scoreDocs;
+			AssertEquals("min and up", numDocs, result.Length);
+			
+			result = search.Search(Csrq("id", null, maxIP, F, T), null, numDocs).scoreDocs;
+			AssertEquals("max and down", numDocs, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, null, F, F), null, numDocs).scoreDocs;
+			AssertEquals("not min, but up", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", null, maxIP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("not max, but down", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, maxIP, T, F), null, numDocs).scoreDocs;
+			AssertEquals("med and up, not max", maxId - medId, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, medIP, F, T), null, numDocs).scoreDocs;
+			AssertEquals("not min, up to med", medId - minId, result.Length);
+			
+			// very small sets
+			
+			result = search.Search(Csrq("id", minIP, minIP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("min,min,F,F", 0, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, minIP, F, F, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("min,min,F,F", 0, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, medIP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("med,med,F,F", 0, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, medIP, F, F, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("med,med,F,F", 0, result.Length);
+			
+			result = search.Search(Csrq("id", maxIP, maxIP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("max,max,F,F", 0, result.Length);
+			
+			result = search.Search(Csrq("id", maxIP, maxIP, F, F, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("max,max,F,F", 0, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, minIP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("min,min,T,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, minIP, T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("min,min,T,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", null, minIP, F, T), null, numDocs).scoreDocs;
+			AssertEquals("nul,min,F,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", null, minIP, F, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("nul,min,F,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", maxIP, maxIP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("max,max,T,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", maxIP, maxIP, T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("max,max,T,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", maxIP, null, T, F), null, numDocs).scoreDocs;
+			AssertEquals("max,nul,T,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", maxIP, null, T, F, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("max,nul,T,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, medIP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("med,med,T,T", 1, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, medIP, T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
+			AssertEquals("med,med,T,T", 1, result.Length);
+		}
+		
+        [Test]
+		public virtual void  TestRangeQueryIdCollating()
+		{
+			// NOTE: uses index build in *super* setUp
+			
+			IndexReader reader = IndexReader.Open(signedIndex.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();
+			
+			AssertEquals("num of docs", numDocs, 1 + maxId - minId);
+			
+			ScoreDoc[] result;
+			
+			System.Globalization.CompareInfo c = new System.Globalization.CultureInfo("en").CompareInfo;
+			
+			// test id, bounded on both ends
+			
+			result = search.Search(Csrq("id", minIP, maxIP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("find all", numDocs, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, T, F, c), null, numDocs).scoreDocs;
+			AssertEquals("all but last", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, F, T, c), null, numDocs).scoreDocs;
+			AssertEquals("all but first", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, maxIP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("all but ends", numDocs - 2, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, maxIP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("med and up", 1 + maxId - medId, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, medIP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("up to med", 1 + medId - minId, result.Length);
+			
+			// unbounded id
+			
+			result = search.Search(Csrq("id", minIP, null, T, F, c), null, numDocs).scoreDocs;
+			AssertEquals("min and up", numDocs, result.Length);
+			
+			result = search.Search(Csrq("id", null, maxIP, F, T, c), null, numDocs).scoreDocs;
+			AssertEquals("max and down", numDocs, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, null, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("not min, but up", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", null, maxIP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("not max, but down", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, maxIP, T, F, c), null, numDocs).scoreDocs;
+			AssertEquals("med and up, not max", maxId - medId, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, medIP, F, T, c), null, numDocs).scoreDocs;
+			AssertEquals("not min, up to med", medId - minId, result.Length);
+			
+			// very small sets
+			
+			result = search.Search(Csrq("id", minIP, minIP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("min,min,F,F,c", 0, result.Length);
+			result = search.Search(Csrq("id", medIP, medIP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("med,med,F,F,c", 0, result.Length);
+			result = search.Search(Csrq("id", maxIP, maxIP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("max,max,F,F,c", 0, result.Length);
+			
+			result = search.Search(Csrq("id", minIP, minIP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("min,min,T,T,c", 1, result.Length);
+			result = search.Search(Csrq("id", null, minIP, F, T, c), null, numDocs).scoreDocs;
+			AssertEquals("nul,min,F,T,c", 1, result.Length);
+			
+			result = search.Search(Csrq("id", maxIP, maxIP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("max,max,T,T,c", 1, result.Length);
+			result = search.Search(Csrq("id", maxIP, null, T, F, c), null, numDocs).scoreDocs;
+			AssertEquals("max,nul,T,T,c", 1, result.Length);
+			
+			result = search.Search(Csrq("id", medIP, medIP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("med,med,T,T,c", 1, result.Length);
+		}
+		
+        [Test]
+		public virtual void  TestRangeQueryRand()
+		{
+			// NOTE: uses index build in *super* setUp
+			
+			IndexReader reader = IndexReader.Open(signedIndex.index);
+			IndexSearcher search = new IndexSearcher(reader);
+			
+			System.String minRP = Pad(signedIndex.minR);
+			System.String maxRP = Pad(signedIndex.maxR);
+			
+			int numDocs = reader.NumDocs();
+			
+			AssertEquals("num of docs", numDocs, 1 + maxId - minId);
+			
+			ScoreDoc[] result;
+			
+			// test extremes, bounded on both ends
+			
+			result = search.Search(Csrq("rand", minRP, maxRP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("find all", numDocs, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, maxRP, T, F), null, numDocs).scoreDocs;
+			AssertEquals("all but biggest", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, maxRP, F, T), null, numDocs).scoreDocs;
+			AssertEquals("all but smallest", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, maxRP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("all but extremes", numDocs - 2, result.Length);
+			
+			// unbounded
+			
+			result = search.Search(Csrq("rand", minRP, null, T, F), null, numDocs).scoreDocs;
+			AssertEquals("smallest and up", numDocs, result.Length);
+			
+			result = search.Search(Csrq("rand", null, maxRP, F, T), null, numDocs).scoreDocs;
+			AssertEquals("biggest and down", numDocs, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, null, F, F), null, numDocs).scoreDocs;
+			AssertEquals("not smallest, but up", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("rand", null, maxRP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("not biggest, but down", numDocs - 1, result.Length);
+			
+			// very small sets
+			
+			result = search.Search(Csrq("rand", minRP, minRP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("min,min,F,F", 0, result.Length);
+			result = search.Search(Csrq("rand", maxRP, maxRP, F, F), null, numDocs).scoreDocs;
+			AssertEquals("max,max,F,F", 0, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, minRP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("min,min,T,T", 1, result.Length);
+			result = search.Search(Csrq("rand", null, minRP, F, T), null, numDocs).scoreDocs;
+			AssertEquals("nul,min,F,T", 1, result.Length);
+			
+			result = search.Search(Csrq("rand", maxRP, maxRP, T, T), null, numDocs).scoreDocs;
+			AssertEquals("max,max,T,T", 1, result.Length);
+			result = search.Search(Csrq("rand", maxRP, null, T, F), null, numDocs).scoreDocs;
+			AssertEquals("max,nul,T,T", 1, result.Length);
+		}
+		
+        [Test]
+		public virtual void  TestRangeQueryRandCollating()
+		{
+			// NOTE: uses index build in *super* setUp
+			
+			// using the unsigned index because collation seems to ignore hyphens
+			IndexReader reader = IndexReader.Open(unsignedIndex.index);
+			IndexSearcher search = new IndexSearcher(reader);
+			
+			System.String minRP = Pad(unsignedIndex.minR);
+			System.String maxRP = Pad(unsignedIndex.maxR);
+			
+			int numDocs = reader.NumDocs();
+			
+			AssertEquals("num of docs", numDocs, 1 + maxId - minId);
+			
+			ScoreDoc[] result;
+			
+			System.Globalization.CompareInfo c = new System.Globalization.CultureInfo("en").CompareInfo;
+			
+			// test extremes, bounded on both ends
+			
+			result = search.Search(Csrq("rand", minRP, maxRP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("find all", numDocs, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, maxRP, T, F, c), null, numDocs).scoreDocs;
+			AssertEquals("all but biggest", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, maxRP, F, T, c), null, numDocs).scoreDocs;
+			AssertEquals("all but smallest", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, maxRP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("all but extremes", numDocs - 2, result.Length);
+			
+			// unbounded
+			
+			result = search.Search(Csrq("rand", minRP, null, T, F, c), null, numDocs).scoreDocs;
+			AssertEquals("smallest and up", numDocs, result.Length);
+			
+			result = search.Search(Csrq("rand", null, maxRP, F, T, c), null, numDocs).scoreDocs;
+			AssertEquals("biggest and down", numDocs, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, null, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("not smallest, but up", numDocs - 1, result.Length);
+			
+			result = search.Search(Csrq("rand", null, maxRP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("not biggest, but down", numDocs - 1, result.Length);
+			
+			// very small sets
+			
+			result = search.Search(Csrq("rand", minRP, minRP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("min,min,F,F,c", 0, result.Length);
+			result = search.Search(Csrq("rand", maxRP, maxRP, F, F, c), null, numDocs).scoreDocs;
+			AssertEquals("max,max,F,F,c", 0, result.Length);
+			
+			result = search.Search(Csrq("rand", minRP, minRP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("min,min,T,T,c", 1, result.Length);
+			result = search.Search(Csrq("rand", null, minRP, F, T, c), null, numDocs).scoreDocs;
+			AssertEquals("nul,min,F,T,c", 1, result.Length);
+			
+			result = search.Search(Csrq("rand", maxRP, maxRP, T, T, c), null, numDocs).scoreDocs;
+			AssertEquals("max,max,T,T,c", 1, result.Length);
+			result = search.Search(Csrq("rand", maxRP, null, T, F, c), null, numDocs).scoreDocs;
+			AssertEquals("max,nul,T,T,c", 1, result.Length);
+		}
+		
+        [Test]
+		public virtual 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.NOT_ANALYZED));
+			doc.Add(new Field("body", "body", Field.Store.YES, Field.Index.NOT_ANALYZED));
+			writer.AddDocument(doc);
+			
+			writer.Optimize();
+			writer.Close();
+			
+			IndexReader reader = IndexReader.Open(farsiIndex);
+			IndexSearcher search = new IndexSearcher(reader);
+			
+			// 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 c = new System.Globalization.CultureInfo("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 ConstantScoreRangeQuery
+			// with a Farsi Collator (or an Arabic one for the case when Farsi is
+			// not supported).
+			ScoreDoc[] result = search.Search(Csrq("content", "\u062F", "\u0698", T, T, c), null, 1000).scoreDocs;
+			AssertEquals("The index Term should not be included.", 0, result.Length);
+			
+			result = search.Search(Csrq("content", "\u0633", "\u0638", T, T, c), null, 1000).scoreDocs;
+			AssertEquals("The index Term should be included.", 1, result.Length);
+			search.Close();
+		}
+		
+        [Test]
+		public virtual void  TestDanish()
+		{
+			
+			/* build an index */
+			RAMDirectory danishIndex = new RAMDirectory();
+			IndexWriter writer = new IndexWriter(danishIndex, new SimpleAnalyzer(), T, IndexWriter.MaxFieldLength.LIMITED);
+			
+			// Danish collation orders the words below in the given order
+			// (example taken from TestSort.testInternationalSort() ).
+			System.String[] words = new System.String[]{"H\u00D8T", "H\u00C5T", "MAND"};
+			for (int docnum = 0; docnum < words.Length; ++docnum)
+			{
+				Document doc = new Document();
+				doc.Add(new Field("content", words[docnum], 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(danishIndex);
+			IndexSearcher search = new IndexSearcher(reader);
+			
+			System.Globalization.CompareInfo c = new System.Globalization.CultureInfo("da" + "-" + "dk").CompareInfo;
+			
+			// Unicode order would not include "H\u00C5T" in [ "H\u00D8T", "MAND" ],
+			// but Danish collation does.
+			ScoreDoc[] result = search.Search(Csrq("content", "H\u00D8T", "MAND", F, F, c), null, 1000).scoreDocs;
+			AssertEquals("The index Term should be included.", 1, result.Length);
+			
+			result = search.Search(Csrq("content", "H\u00C5T", "MAND", F, F, c), null, 1000).scoreDocs;
+			AssertEquals("The index Term should not be included.", 0, result.Length);
+			search.Close();
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiThreadTermVectors.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestMultiThreadTermVectors.cs?rev=832486&r1=832485&r2=832486&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiThreadTermVectors.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiThreadTermVectors.cs Tue Nov  3 18:06:27 2009
@@ -1,4 +1,4 @@
-/*
+/* 
  * 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.
@@ -19,6 +19,7 @@
 
 using NUnit.Framework;
 
+using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
 using Lucene.Net.Documents;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using IndexWriter = Lucene.Net.Index.IndexWriter;
@@ -26,32 +27,34 @@
 using RAMDirectory = Lucene.Net.Store.RAMDirectory;
 using English = Lucene.Net.Util.English;
 using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
-using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
 
 namespace Lucene.Net.Search
 {
 	
 	/// <summary> </summary>
-	/// <version>  $rcs = ' $Id: TestMultiThreadTermVectors.java 583534 2007-10-10 16:46:35Z mikemccand $ ' ;
+	/// <version>  $rcs = ' $Id: TestMultiThreadTermVectors.java 759556 2009-03-28 19:10:55Z mikemccand $ ' ;
 	/// </version>
-	[TestFixture]
-	public class TestMultiThreadTermVectors : LuceneTestCase
+    [TestFixture]
+	public class TestMultiThreadTermVectors:LuceneTestCase
 	{
 		private RAMDirectory directory = new RAMDirectory();
 		public int numDocs = 100;
 		public int numThreads = 3;
 		
+		public TestMultiThreadTermVectors(System.String s):base(s)
+		{
+		}
 		
-		[SetUp]
-		public override void SetUp()
+		[Test]
+		public override void  SetUp()
 		{
 			base.SetUp();
-            IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+			IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			//writer.setUseCompoundFile(false);
 			//writer.infoStream = System.out;
 			for (int i = 0; i < numDocs; i++)
 			{
-				Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
+				Document doc = new Document();
 				Fieldable fld = new Field("field", English.IntToEnglish(i), Field.Store.YES, Field.Index.NOT_ANALYZED, Field.TermVector.YES);
 				doc.Add(fld);
 				writer.AddDocument(doc);
@@ -69,7 +72,7 @@
 			{
 				reader = IndexReader.Open(directory);
 				for (int i = 1; i <= numThreads; i++)
-					_TestTermPositionVectors(reader, i);
+					TestTermPositionVectors(reader, i);
 			}
 			catch (System.IO.IOException ioe)
 			{
@@ -92,7 +95,8 @@
 			}
 		}
 		
-		public virtual void  _TestTermPositionVectors(IndexReader reader, int threadCount)
+		[Test]
+		public virtual void  TestTermPositionVectors(IndexReader reader, int threadCount)
 		{
 			MultiThreadTermVectorsReader[] mtr = new MultiThreadTermVectorsReader[threadCount];
 			for (int i = 0; i < threadCount; i++)
@@ -106,23 +110,17 @@
 			int threadsAlive = mtr.Length;
 			while (threadsAlive > 0)
 			{
-				try
+				//System.out.println("Threads alive");
+				System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 10));
+				threadsAlive = mtr.Length;
+				for (int i = 0; i < mtr.Length; i++)
 				{
-					//System.out.println("Threads alive");
-					System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 10));
-					threadsAlive = mtr.Length;
-					for (int i = 0; i < mtr.Length; i++)
+					if (mtr[i].IsAlive() == true)
 					{
-						if (mtr[i].IsAlive() == true)
-						{
-							break;
-						}
-						
-						threadsAlive--;
+						break;
 					}
-				}
-				catch (System.Threading.ThreadInterruptedException)
-				{
+					
+					threadsAlive--;
 				}
 			}
 			
@@ -218,7 +216,7 @@
 			}
 			
 			if (!English.IntToEnglish(num).Trim().Equals(temp.ToString().Trim()))
-				System.Console.Out.WriteLine("worng term result");
+				System.Console.Out.WriteLine("wrong term result");
 		}
 	}
 }
\ No newline at end of file

Added: incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiValuedNumericRangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestMultiValuedNumericRangeQuery.cs?rev=832486&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiValuedNumericRangeQuery.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestMultiValuedNumericRangeQuery.cs Tue Nov  3 18:06:27 2009
@@ -0,0 +1,89 @@
+/* 
+ * 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 System;
+
+using NUnit.Framework;
+
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using NumericField = Lucene.Net.Documents.NumericField;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using MaxFieldLength = Lucene.Net.Index.IndexWriter.MaxFieldLength;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
+
+namespace Lucene.Net.Search
+{
+	
+    [TestFixture]
+	public class TestMultiValuedNumericRangeQuery:LuceneTestCase
+	{
+		
+		/// <summary>Tests NumericRangeQuery on a multi-valued field (multiple numeric values per document).
+		/// This test ensures, that a classical TermRangeQuery returns exactly the same document numbers as
+		/// NumericRangeQuery (see SOLR-1322 for discussion) and the multiple precision terms per numeric value
+		/// do not interfere with multiple numeric values.
+		/// </summary>
+		
+        [Test]
+		public virtual void  TestMultiValuedNRQ()
+		{
+			System.Random rnd = NewRandom();
+			
+			RAMDirectory directory = new RAMDirectory();
+			IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, MaxFieldLength.UNLIMITED);
+			
+			//DecimalFormat format = new DecimalFormat("00000000000", new System.Globalization.CultureInfo("en-US").NumberFormat);
+			
+			for (int l = 0; l < 5000; l++)
+			{
+				Document doc = new Document();
+				for (int m = 0, c = rnd.Next(10); m <= c; m++)
+				{
+					int value_Renamed = rnd.Next(System.Int32.MaxValue);
+                    doc.Add(new Field("asc", "{00000000000}", Field.Store.NO, Field.Index.NOT_ANALYZED));
+					doc.Add(new NumericField("trie", Field.Store.NO, true).SetIntValue(value_Renamed));
+				}
+				writer.AddDocument(doc);
+			}
+			writer.Close();
+			
+			Searcher searcher = new IndexSearcher(directory, true);
+			for (int i = 0; i < 50; i++)
+			{
+				int lower = rnd.Next(System.Int32.MaxValue);
+				int upper = rnd.Next(System.Int32.MaxValue);
+				if (lower > upper)
+				{
+					int a = lower; lower = upper; upper = a;
+				}
+				TermRangeQuery cq = new TermRangeQuery("asc", "{" + lower.ToString() + "}", "{" + upper.ToString() + "}", true, true);
+				System.Int32 tempAux = (System.Int32) lower;
+				System.Int32 tempAux2 = (System.Int32) upper;
+				NumericRangeQuery tq = NumericRangeQuery.NewIntRange("trie", tempAux, tempAux2, true, true);
+				TopDocs trTopDocs = searcher.Search(cq, 1);
+				TopDocs nrTopDocs = searcher.Search(tq, 1);
+				Assert.AreEqual(trTopDocs.totalHits, nrTopDocs.totalHits, "Returned count for NumericRangeQuery and TermRangeQuery must be equal");
+			}
+			searcher.Close();
+			
+			directory.Close();
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestNot.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestNot.cs?rev=832486&r1=832485&r2=832486&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestNot.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestNot.cs Tue Nov  3 18:06:27 2009
@@ -1,4 +1,4 @@
-/*
+/* 
  * 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.
@@ -19,12 +19,12 @@
 
 using NUnit.Framework;
 
+using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
 using Document = Lucene.Net.Documents.Document;
 using Field = Lucene.Net.Documents.Field;
 using IndexWriter = Lucene.Net.Index.IndexWriter;
 using QueryParser = Lucene.Net.QueryParsers.QueryParser;
 using RAMDirectory = Lucene.Net.Store.RAMDirectory;
-using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
 using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
 
 namespace Lucene.Net.Search
@@ -34,19 +34,22 @@
 	/// 
 	/// 
 	/// </summary>
-	/// <version>  $Revision: 583534 $
+	/// <version>  $Revision: 694004 $
 	/// </version>
-	[TestFixture]
-	public class TestNot : LuceneTestCase
+    [TestFixture]
+	public class TestNot:LuceneTestCase
 	{
+		public TestNot(System.String name):base(name)
+		{
+		}
 		
 		[Test]
-		public virtual void  TestNot_Renamed_Method()
+		public virtual void  TestNot_Renamed()
 		{
 			RAMDirectory store = new RAMDirectory();
-            IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+			IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
 			
-			Lucene.Net.Documents.Document d1 = new Lucene.Net.Documents.Document();
+			Document d1 = new Document();
 			d1.Add(new Field("field", "a b", Field.Store.YES, Field.Index.ANALYZED));
 			
 			writer.AddDocument(d1);
@@ -54,8 +57,8 @@
 			writer.Close();
 			
 			Searcher searcher = new IndexSearcher(store);
-			Lucene.Net.QueryParsers.QueryParser parser = new Lucene.Net.QueryParsers.QueryParser("field", new SimpleAnalyzer());
-			Lucene.Net.Search.Query query = parser.Parse("a NOT b");
+			QueryParser parser = new QueryParser("field", new SimpleAnalyzer());
+			Query query = parser.Parse("a NOT b");
 			//System.out.println(query);
 			ScoreDoc[] hits = searcher.Search(query, null, 1000).scoreDocs;
 			Assert.AreEqual(0, hits.Length);

Added: incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery32.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestNumericRangeQuery32.cs?rev=832486&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery32.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery32.cs Tue Nov  3 18:06:27 2009
@@ -0,0 +1,565 @@
+/* 
+ * 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 System;
+
+using NUnit.Framework;
+
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using NumericField = Lucene.Net.Documents.NumericField;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using MaxFieldLength = Lucene.Net.Index.IndexWriter.MaxFieldLength;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using NumericUtils = Lucene.Net.Util.NumericUtils;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
+
+namespace Lucene.Net.Search
+{
+	
+    [TestFixture]
+	public class TestNumericRangeQuery32:LuceneTestCase
+	{
+		// distance of entries
+		private const int distance = 6666;
+		// shift the starting of the values to the left, to also have negative values:
+		private const int startOffset = - 1 << 15;
+		// number of docs to generate for testing
+		private const int noDocs = 10000;
+		
+		private static RAMDirectory directory;
+		private static IndexSearcher searcher;
+		
+		/// <summary>test for both constant score and boolean query, the other tests only use the constant score mode </summary>
+		private void  TestRange(int precisionStep)
+		{
+			System.String field = "field" + precisionStep;
+			int count = 3000;
+			int lower = (distance * 3 / 2) + startOffset, upper = lower + count * distance + (distance / 3);
+			System.Int32 tempAux = (System.Int32) lower;
+			System.Int32 tempAux2 = (System.Int32) upper;
+			NumericRangeQuery q = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux, tempAux2, true, true);
+			System.Int32 tempAux3 = (System.Int32) lower;
+			System.Int32 tempAux4 = (System.Int32) upper;
+			NumericRangeFilter f = NumericRangeFilter.NewIntRange(field, precisionStep, tempAux3, tempAux4, true, true);
+			int lastTerms = 0;
+			for (sbyte i = 0; i < 3; i++)
+			{
+				TopDocs topDocs;
+				int terms;
+				System.String type;
+				q.ClearTotalNumberOfTerms();
+				f.ClearTotalNumberOfTerms();
+				switch (i)
+				{
+					
+					case 0: 
+						type = " (constant score filter rewrite)";
+						q.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE);
+						topDocs = searcher.Search(q, null, noDocs, Sort.INDEXORDER);
+						terms = q.GetTotalNumberOfTerms();
+						break;
+					
+					case 1: 
+						type = " (constant score boolean rewrite)";
+						q.SetRewriteMethod(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE);
+						topDocs = searcher.Search(q, null, noDocs, Sort.INDEXORDER);
+						terms = q.GetTotalNumberOfTerms();
+						break;
+					
+					case 2: 
+						type = " (filter)";
+						topDocs = searcher.Search(new MatchAllDocsQuery(), f, noDocs, Sort.INDEXORDER);
+						terms = f.GetTotalNumberOfTerms();
+						break;
+					
+					default: 
+						return ;
+					
+				}
+				System.Console.Out.WriteLine("Found " + terms + " distinct terms in range for field '" + field + "'" + type + ".");
+				ScoreDoc[] sd = topDocs.scoreDocs;
+				Assert.IsNotNull(sd);
+				Assert.AreEqual(count, sd.Length, "Score doc count" + type);
+				Document doc = searcher.Doc(sd[0].doc);
+				Assert.AreEqual(2 * distance + startOffset, System.Int32.Parse(doc.Get(field)), "First doc" + type);
+				doc = searcher.Doc(sd[sd.Length - 1].doc);
+				Assert.AreEqual((1 + count) * distance + startOffset, System.Int32.Parse(doc.Get(field)), "Last doc" + type);
+				if (i > 0)
+				{
+					Assert.AreEqual(lastTerms, terms, "Distinct term number is equal for all query types");
+				}
+				lastTerms = terms;
+			}
+		}
+		
+        [Test]
+		public virtual void  TestRange_8bit()
+		{
+			TestRange(8);
+		}
+		
+        [Test]
+		public virtual void  TestRange_4bit()
+		{
+			TestRange(4);
+		}
+		
+        [Test]
+		public virtual void  TestRange_2bit()
+		{
+			TestRange(2);
+		}
+		
+        [Test]
+		public virtual void  TestInverseRange()
+		{
+			System.Int32 tempAux = 1000;
+			System.Int32 tempAux2 = - 1000;
+			NumericRangeFilter f = NumericRangeFilter.NewIntRange("field8", 8, tempAux, tempAux2, true, true);
+			Assert.AreSame(DocIdSet.EMPTY_DOCIDSET, f.GetDocIdSet(searcher.GetIndexReader()), "A inverse range should return the EMPTY_DOCIDSET instance");
+			//UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
+			System.Int32 tempAux3 = (System.Int32) System.Int32.MaxValue;
+			f = NumericRangeFilter.NewIntRange("field8", 8, tempAux3, null, false, false);
+			Assert.AreSame(DocIdSet.EMPTY_DOCIDSET, f.GetDocIdSet(searcher.GetIndexReader()), "A exclusive range starting with Integer.MAX_VALUE should return the EMPTY_DOCIDSET instance");
+			//UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
+			System.Int32 tempAux4 = (System.Int32) System.Int32.MinValue;
+			f = NumericRangeFilter.NewIntRange("field8", 8, null, tempAux4, false, false);
+			Assert.AreSame(DocIdSet.EMPTY_DOCIDSET, f.GetDocIdSet(searcher.GetIndexReader()), "A exclusive range ending with Integer.MIN_VALUE should return the EMPTY_DOCIDSET instance");
+		}
+		
+		private void  TestLeftOpenRange(int precisionStep)
+		{
+			System.String field = "field" + precisionStep;
+			int count = 3000;
+			int upper = (count - 1) * distance + (distance / 3) + startOffset;
+			//UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
+			System.Int32 tempAux = (System.Int32) upper;
+			NumericRangeQuery q = NumericRangeQuery.NewIntRange(field, precisionStep, null, tempAux, true, true);
+			TopDocs topDocs = searcher.Search(q, null, noDocs, Sort.INDEXORDER);
+			System.Console.Out.WriteLine("Found " + q.GetTotalNumberOfTerms() + " distinct terms in left open range for field '" + field + "'.");
+			ScoreDoc[] sd = topDocs.scoreDocs;
+			Assert.IsNotNull(sd);
+			Assert.AreEqual(count, sd.Length, "Score doc count");
+			Document doc = searcher.Doc(sd[0].doc);
+			Assert.AreEqual(startOffset, System.Int32.Parse(doc.Get(field)), "First doc");
+			doc = searcher.Doc(sd[sd.Length - 1].doc);
+			Assert.AreEqual((count - 1) * distance + startOffset, System.Int32.Parse(doc.Get(field)), "Last doc");
+		}
+		
+        [Test]
+		public virtual void  TestLeftOpenRange_8bit()
+		{
+			TestLeftOpenRange(8);
+		}
+		
+        [Test]
+		public virtual void  TestLeftOpenRange_4bit()
+		{
+			TestLeftOpenRange(4);
+		}
+		
+        [Test]
+		public virtual void  TestLeftOpenRange_2bit()
+		{
+			TestLeftOpenRange(2);
+		}
+		
+		private void  TestRightOpenRange(int precisionStep)
+		{
+			System.String field = "field" + precisionStep;
+			int count = 3000;
+			int lower = (count - 1) * distance + (distance / 3) + startOffset;
+			//UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
+			System.Int32 tempAux = (System.Int32) lower;
+			NumericRangeQuery q = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux, null, true, true);
+			TopDocs topDocs = searcher.Search(q, null, noDocs, Sort.INDEXORDER);
+			System.Console.Out.WriteLine("Found " + q.GetTotalNumberOfTerms() + " distinct terms in right open range for field '" + field + "'.");
+			ScoreDoc[] sd = topDocs.scoreDocs;
+			Assert.IsNotNull(sd);
+			Assert.AreEqual(noDocs - count, sd.Length, "Score doc count");
+			Document doc = searcher.Doc(sd[0].doc);
+			Assert.AreEqual(count * distance + startOffset, System.Int32.Parse(doc.Get(field)), "First doc");
+			doc = searcher.Doc(sd[sd.Length - 1].doc);
+			Assert.AreEqual((noDocs - 1) * distance + startOffset, System.Int32.Parse(doc.Get(field)), "Last doc");
+		}
+		
+        [Test]
+		public virtual void  TestRightOpenRange_8bit()
+		{
+			TestRightOpenRange(8);
+		}
+		
+        [Test]
+		public virtual void  TestRightOpenRange_4bit()
+		{
+			TestRightOpenRange(4);
+		}
+		
+        [Test]
+		public virtual void  TestRightOpenRange_2bit()
+		{
+			TestRightOpenRange(2);
+		}
+		
+		private void  TestRandomTrieAndClassicRangeQuery(int precisionStep)
+		{
+			System.Random rnd = NewRandom();
+			System.String field = "field" + precisionStep;
+			int termCountT = 0, termCountC = 0;
+			for (int i = 0; i < 50; i++)
+			{
+				int lower = (int) (rnd.NextDouble() * noDocs * distance) + startOffset;
+				int upper = (int) (rnd.NextDouble() * noDocs * distance) + startOffset;
+				if (lower > upper)
+				{
+					int a = lower; lower = upper; upper = a;
+				}
+				// test inclusive range
+				System.Int32 tempAux = (System.Int32) lower;
+				System.Int32 tempAux2 = (System.Int32) upper;
+				NumericRangeQuery tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux, tempAux2, true, true);
+				TermRangeQuery cq = new TermRangeQuery(field, NumericUtils.IntToPrefixCoded(lower), NumericUtils.IntToPrefixCoded(upper), true, true);
+				TopDocs tTopDocs = searcher.Search(tq, 1);
+				TopDocs cTopDocs = searcher.Search(cq, 1);
+				Assert.AreEqual(cTopDocs.totalHits, tTopDocs.totalHits, "Returned count for NumericRangeQuery and TermRangeQuery must be equal");
+				termCountT += tq.GetTotalNumberOfTerms();
+				termCountC += cq.GetTotalNumberOfTerms();
+				// test exclusive range
+				System.Int32 tempAux3 = (System.Int32) lower;
+				System.Int32 tempAux4 = (System.Int32) upper;
+				tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux3, tempAux4, false, false);
+				cq = new TermRangeQuery(field, NumericUtils.IntToPrefixCoded(lower), NumericUtils.IntToPrefixCoded(upper), false, false);
+				tTopDocs = searcher.Search(tq, 1);
+				cTopDocs = searcher.Search(cq, 1);
+				Assert.AreEqual(cTopDocs.totalHits, tTopDocs.totalHits, "Returned count for NumericRangeQuery and TermRangeQuery must be equal");
+				termCountT += tq.GetTotalNumberOfTerms();
+				termCountC += cq.GetTotalNumberOfTerms();
+				// test left exclusive range
+				System.Int32 tempAux5 = (System.Int32) lower;
+				System.Int32 tempAux6 = (System.Int32) upper;
+				tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux5, tempAux6, false, true);
+				cq = new TermRangeQuery(field, NumericUtils.IntToPrefixCoded(lower), NumericUtils.IntToPrefixCoded(upper), false, true);
+				tTopDocs = searcher.Search(tq, 1);
+				cTopDocs = searcher.Search(cq, 1);
+				Assert.AreEqual(cTopDocs.totalHits, tTopDocs.totalHits, "Returned count for NumericRangeQuery and TermRangeQuery must be equal");
+				termCountT += tq.GetTotalNumberOfTerms();
+				termCountC += cq.GetTotalNumberOfTerms();
+				// test right exclusive range
+				System.Int32 tempAux7 = (System.Int32) lower;
+				System.Int32 tempAux8 = (System.Int32) upper;
+				tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux7, tempAux8, true, false);
+				cq = new TermRangeQuery(field, NumericUtils.IntToPrefixCoded(lower), NumericUtils.IntToPrefixCoded(upper), true, false);
+				tTopDocs = searcher.Search(tq, 1);
+				cTopDocs = searcher.Search(cq, 1);
+				Assert.AreEqual(cTopDocs.totalHits, tTopDocs.totalHits, "Returned count for NumericRangeQuery and TermRangeQuery must be equal");
+				termCountT += tq.GetTotalNumberOfTerms();
+				termCountC += cq.GetTotalNumberOfTerms();
+			}
+			if (precisionStep == System.Int32.MaxValue)
+			{
+				Assert.AreEqual(termCountT, termCountC, "Total number of terms should be equal for unlimited precStep");
+			}
+			else
+			{
+				System.Console.Out.WriteLine("Average number of terms during random search on '" + field + "':");
+				System.Console.Out.WriteLine(" Trie query: " + (((double) termCountT) / (50 * 4)));
+				System.Console.Out.WriteLine(" Classical query: " + (((double) termCountC) / (50 * 4)));
+			}
+		}
+		
+        [Test]
+		public virtual void  TestRandomTrieAndClassicRangeQuery_8bit()
+		{
+			TestRandomTrieAndClassicRangeQuery(8);
+		}
+		
+        [Test]
+		public virtual void  TestRandomTrieAndClassicRangeQuery_4bit()
+		{
+			TestRandomTrieAndClassicRangeQuery(4);
+		}
+		
+        [Test]
+		public virtual void  TestRandomTrieAndClassicRangeQuery_2bit()
+		{
+			TestRandomTrieAndClassicRangeQuery(2);
+		}
+		
+        [Test]
+		public virtual void  TestRandomTrieAndClassicRangeQuery_NoTrie()
+		{
+			TestRandomTrieAndClassicRangeQuery(System.Int32.MaxValue);
+		}
+		
+		private void  TestRangeSplit(int precisionStep)
+		{
+			System.Random rnd = NewRandom();
+			System.String field = "ascfield" + precisionStep;
+			// 50 random tests
+			for (int i = 0; i < 50; i++)
+			{
+				int lower = (int) (rnd.NextDouble() * noDocs - noDocs / 2);
+				int upper = (int) (rnd.NextDouble() * noDocs - noDocs / 2);
+				if (lower > upper)
+				{
+					int a = lower; lower = upper; upper = a;
+				}
+				// test inclusive range
+				System.Int32 tempAux = (System.Int32) lower;
+				System.Int32 tempAux2 = (System.Int32) upper;
+				Query tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux, tempAux2, true, true);
+				TopDocs tTopDocs = searcher.Search(tq, 1);
+				Assert.AreEqual(upper - lower + 1, tTopDocs.totalHits, "Returned count of range query must be equal to inclusive range length");
+				// test exclusive range
+				System.Int32 tempAux3 = (System.Int32) lower;
+				System.Int32 tempAux4 = (System.Int32) upper;
+				tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux3, tempAux4, false, false);
+				tTopDocs = searcher.Search(tq, 1);
+				Assert.AreEqual(System.Math.Max(upper - lower - 1, 0), tTopDocs.totalHits, "Returned count of range query must be equal to exclusive range length");
+				// test left exclusive range
+				System.Int32 tempAux5 = (System.Int32) lower;
+				System.Int32 tempAux6 = (System.Int32) upper;
+				tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux5, tempAux6, false, true);
+				tTopDocs = searcher.Search(tq, 1);
+				Assert.AreEqual(upper - lower, tTopDocs.totalHits, "Returned count of range query must be equal to half exclusive range length");
+				// test right exclusive range
+				System.Int32 tempAux7 = (System.Int32) lower;
+				System.Int32 tempAux8 = (System.Int32) upper;
+				tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux7, tempAux8, true, false);
+				tTopDocs = searcher.Search(tq, 1);
+				Assert.AreEqual(upper - lower, tTopDocs.totalHits, "Returned count of range query must be equal to half exclusive range length");
+			}
+		}
+		
+        [Test]
+		public virtual void  TestRangeSplit_8bit()
+		{
+			TestRangeSplit(8);
+		}
+		
+        [Test]
+		public virtual void  TestRangeSplit_4bit()
+		{
+			TestRangeSplit(4);
+		}
+		
+        [Test]
+		public virtual void  TestRangeSplit_2bit()
+		{
+			TestRangeSplit(2);
+		}
+		
+		/// <summary>we fake a float test using int2float conversion of NumericUtils </summary>
+		private void  TestFloatRange(int precisionStep)
+		{
+			System.String field = "ascfield" + precisionStep;
+			int lower = - 1000;
+			int upper = + 2000;
+			
+			System.Single tempAux = (float) NumericUtils.SortableIntToFloat(lower);
+			System.Single tempAux2 = (float) NumericUtils.SortableIntToFloat(upper);
+			Query tq = NumericRangeQuery.NewFloatRange(field, precisionStep, tempAux, tempAux2, true, true);
+			TopDocs tTopDocs = searcher.Search(tq, 1);
+			Assert.AreEqual(upper - lower + 1, tTopDocs.totalHits, "Returned count of range query must be equal to inclusive range length");
+			
+			System.Single tempAux3 = (float) NumericUtils.SortableIntToFloat(lower);
+			System.Single tempAux4 = (float) NumericUtils.SortableIntToFloat(upper);
+			Filter tf = NumericRangeFilter.NewFloatRange(field, precisionStep, tempAux3, tempAux4, true, true);
+			tTopDocs = searcher.Search(new MatchAllDocsQuery(), tf, 1);
+			Assert.AreEqual(upper - lower + 1, tTopDocs.totalHits, "Returned count of range filter must be equal to inclusive range length");
+		}
+		
+        [Test]
+		public virtual void  TestFloatRange_8bit()
+		{
+			TestFloatRange(8);
+		}
+		
+        [Test]
+		public virtual void  TestFloatRange_4bit()
+		{
+			TestFloatRange(4);
+		}
+		
+        [Test]
+		public virtual void  TestFloatRange_2bit()
+		{
+			TestFloatRange(2);
+		}
+		
+		private void  TestSorting(int precisionStep)
+		{
+			System.Random rnd = NewRandom();
+			System.String field = "field" + precisionStep;
+			// 10 random tests, the index order is ascending,
+			// so using a reverse sort field should retun descending documents
+			for (int i = 0; i < 10; i++)
+			{
+				int lower = (int) (rnd.NextDouble() * noDocs * distance) + startOffset;
+				int upper = (int) (rnd.NextDouble() * noDocs * distance) + startOffset;
+				if (lower > upper)
+				{
+					int a = lower; lower = upper; upper = a;
+				}
+				System.Int32 tempAux = (System.Int32) lower;
+				System.Int32 tempAux2 = (System.Int32) upper;
+				Query tq = NumericRangeQuery.NewIntRange(field, precisionStep, tempAux, tempAux2, true, true);
+				TopDocs topDocs = searcher.Search(tq, null, noDocs, new Sort(new SortField(field, SortField.INT, true)));
+				if (topDocs.totalHits == 0)
+					continue;
+				ScoreDoc[] sd = topDocs.scoreDocs;
+				Assert.IsNotNull(sd);
+				int last = System.Int32.Parse(searcher.Doc(sd[0].doc).Get(field));
+				for (int j = 1; j < sd.Length; j++)
+				{
+					int act = System.Int32.Parse(searcher.Doc(sd[j].doc).Get(field));
+					Assert.IsTrue(last > act, "Docs should be sorted backwards");
+					last = act;
+				}
+			}
+		}
+		
+        [Test]
+		public virtual void  TestSorting_8bit()
+		{
+			TestSorting(8);
+		}
+		
+        [Test]
+		public virtual void  TestSorting_4bit()
+		{
+			TestSorting(4);
+		}
+		
+        [Test]
+		public virtual void  TestSorting_2bit()
+		{
+			TestSorting(2);
+		}
+		
+        [Test]
+		public virtual void  TestEqualsAndHash()
+		{
+			System.Int32 tempAux = 10;
+			System.Int32 tempAux2 = 20;
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test1", 4, tempAux, tempAux2, true, true));
+			System.Int32 tempAux3 = 10;
+			System.Int32 tempAux4 = 20;
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test2", 4, tempAux3, tempAux4, false, true));
+			System.Int32 tempAux5 = 10;
+			System.Int32 tempAux6 = 20;
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test3", 4, tempAux5, tempAux6, true, false));
+			System.Int32 tempAux7 = 10;
+			System.Int32 tempAux8 = 20;
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test4", 4, tempAux7, tempAux8, false, false));
+			//UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
+			System.Int32 tempAux9 = 10;
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test5", 4, tempAux9, null, true, true));
+			//UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
+			System.Int32 tempAux10 = 20;
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test6", 4, null, tempAux10, true, true));
+			//UPGRADE_TODO: The 'System.Int32' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test7", 4, null, null, true, true));
+			System.Int32 tempAux11 = 10;
+			System.Int32 tempAux12 = 20;
+			System.Int32 tempAux13 = 10;
+			System.Int32 tempAux14 = 20;
+			QueryUtils.CheckEqual(NumericRangeQuery.NewIntRange("test8", 4, tempAux11, tempAux12, true, true), NumericRangeQuery.NewIntRange("test8", 4, tempAux13, tempAux14, true, true));
+			System.Int32 tempAux15 = 10;
+			System.Int32 tempAux16 = 20;
+			System.Int32 tempAux17 = 10;
+			System.Int32 tempAux18 = 20;
+			QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test9", 4, tempAux15, tempAux16, true, true), NumericRangeQuery.NewIntRange("test9", 8, tempAux17, tempAux18, true, true));
+			System.Int32 tempAux19 = 10;
+			System.Int32 tempAux20 = 20;
+			System.Int32 tempAux21 = 10;
+			System.Int32 tempAux22 = 20;
+			QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test10a", 4, tempAux19, tempAux20, true, true), NumericRangeQuery.NewIntRange("test10b", 4, tempAux21, tempAux22, true, true));
+			System.Int32 tempAux23 = 10;
+			System.Int32 tempAux24 = 20;
+			System.Int32 tempAux25 = 20;
+			System.Int32 tempAux26 = 10;
+			QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test11", 4, tempAux23, tempAux24, true, true), NumericRangeQuery.NewIntRange("test11", 4, tempAux25, tempAux26, true, true));
+			System.Int32 tempAux27 = 10;
+			System.Int32 tempAux28 = 20;
+			System.Int32 tempAux29 = 10;
+			System.Int32 tempAux30 = 20;
+			QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test12", 4, tempAux27, tempAux28, true, true), NumericRangeQuery.NewIntRange("test12", 4, tempAux29, tempAux30, false, true));
+			System.Int32 tempAux31 = 10;
+			System.Int32 tempAux32 = 20;
+			System.Single tempAux33 = (float) 10f;
+			System.Single tempAux34 = (float) 20f;
+			QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test13", 4, tempAux31, tempAux32, true, true), NumericRangeQuery.NewFloatRange("test13", 4, tempAux33, tempAux34, true, true));
+			// the following produces a hash collision, because Long and Integer have the same hashcode, so only test equality:
+			System.Int32 tempAux35 = 10;
+			System.Int32 tempAux36 = 20;
+			Query q1 = NumericRangeQuery.NewIntRange("test14", 4, tempAux35, tempAux36, true, true);
+			System.Int64 tempAux37 = 10L;
+			System.Int64 tempAux38 = 20L;
+			Query q2 = NumericRangeQuery.NewLongRange("test14", 4, tempAux37, tempAux38, true, true);
+			Assert.IsFalse(q1.Equals(q2));
+			Assert.IsFalse(q2.Equals(q1));
+		}
+		static TestNumericRangeQuery32()
+		{
+			{
+				try
+				{
+					// set the theoretical maximum term count for 8bit (see docs for the number)
+					BooleanQuery.SetMaxClauseCount(3 * 255 * 2 + 255);
+					
+					directory = new RAMDirectory();
+					IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, MaxFieldLength.UNLIMITED);
+					
+					NumericField field8 = new NumericField("field8", 8, Field.Store.YES, true), field4 = new NumericField("field4", 4, Field.Store.YES, true), field2 = new NumericField("field2", 2, Field.Store.YES, true), fieldNoTrie = new NumericField("field" + System.Int32.MaxValue, System.Int32.MaxValue, Field.Store.YES, true), ascfield8 = new NumericField("ascfield8", 8, Field.Store.NO, true), ascfield4 = new NumericField("ascfield4", 4, Field.Store.NO, true), ascfield2 = new NumericField("ascfield2", 2, Field.Store.NO, true);
+					
+					Document doc = new Document();
+					// add fields, that have a distance to test general functionality
+					doc.Add(field8); doc.Add(field4); doc.Add(field2); doc.Add(fieldNoTrie);
+					// add ascending fields with a distance of 1, beginning at -noDocs/2 to test the correct splitting of range and inclusive/exclusive
+					doc.Add(ascfield8); doc.Add(ascfield4); doc.Add(ascfield2);
+					
+					// Add a series of noDocs docs with increasing int values
+					for (int l = 0; l < noDocs; l++)
+					{
+						int val = distance * l + startOffset;
+						field8.SetIntValue(val);
+						field4.SetIntValue(val);
+						field2.SetIntValue(val);
+						fieldNoTrie.SetIntValue(val);
+						
+						val = l - (noDocs / 2);
+						ascfield8.SetIntValue(val);
+						ascfield4.SetIntValue(val);
+						ascfield2.SetIntValue(val);
+						writer.AddDocument(doc);
+					}
+					
+					writer.Optimize();
+					writer.Close();
+					searcher = new IndexSearcher(directory, true);
+				}
+				catch (System.Exception e)
+				{
+					throw new System.SystemException("", e);
+				}
+			}
+		}
+	}
+}
\ No newline at end of file