lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccurr...@apache.org
Subject [Lucene.Net] svn commit: r1294875 [42/45] - in /incubator/lucene.net/trunk: ./ build/ build/vs2010/contrib/ build/vs2010/test/ doc/ src/ src/contrib/Analyzers/ src/contrib/Analyzers/AR/ src/contrib/Analyzers/BR/ src/contrib/Analyzers/CJK/ src/contrib/Analyzers/Cn/ ...
Date Tue, 28 Feb 2012 22:43:28 GMT
Modified: incubator/lucene.net/trunk/test/core/Search/TestFuzzyQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestFuzzyQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestFuzzyQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestFuzzyQuery.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using System.Collections.Generic;
 using NUnit.Framework;
 
 using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
@@ -41,138 +41,174 @@ namespace Lucene.Net.Search
     [TestFixture]
 	public class TestFuzzyQuery:LuceneTestCase
 	{
-		
-		[Test]
-		public virtual void  TestFuzziness()
-		{
-			RAMDirectory directory = new RAMDirectory();
-			IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
-			AddDoc("aaaaa", writer);
-			AddDoc("aaaab", writer);
-			AddDoc("aaabb", writer);
-			AddDoc("aabbb", writer);
-			AddDoc("abbbb", writer);
-			AddDoc("bbbbb", writer);
-			AddDoc("ddddd", writer);
-			writer.Optimize();
-			writer.Close();
-			IndexSearcher searcher = new IndexSearcher(directory);
-			
-			FuzzyQuery query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 0);
-			ScoreDoc[] hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			
-			// same with prefix
-			query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 1);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 2);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 3);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 4);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(2, hits.Length);
-			query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 5);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(1, hits.Length);
-			query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 6);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(1, hits.Length);
-			
-			// not similar enough:
-			query = new FuzzyQuery(new Term("field", "xxxxx"), FuzzyQuery.defaultMinSimilarity, 0);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(0, hits.Length);
-			query = new FuzzyQuery(new Term("field", "aaccc"), FuzzyQuery.defaultMinSimilarity, 0); // edit distance to "aaaaa" = 3
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(0, hits.Length);
-			
-			// query identical to a word in the index:
-			query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 0);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
-			// default allows for up to two edits:
-			Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
-			Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
-			
-			// query similar to a word in the index:
-			query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 0);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
-			Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
-			Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
-			
-			// now with prefix
-			query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 1);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
-			Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
-			Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
-			query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 2);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
-			Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
-			Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
-			query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 3);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(3, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
-			Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
-			Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
-			query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 4);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(2, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
-			Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
-			query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 5);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(0, hits.Length);
-			
-			
-			query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 0);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(1, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
-			
-			// now with prefix
-			query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 1);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(1, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
-			query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 2);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(1, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
-			query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 3);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(1, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
-			query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 4);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(1, hits.Length);
-			Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
-			query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 5);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(0, hits.Length);
-			
-			
-			// different field = no match:
-			query = new FuzzyQuery(new Term("anotherfield", "ddddX"), FuzzyQuery.defaultMinSimilarity, 0);
-			hits = searcher.Search(query, null, 1000).ScoreDocs;
-			Assert.AreEqual(0, hits.Length);
-			
-			searcher.Close();
-			directory.Close();
-		}
-		
-		[Test]
+
+        [Test]
+        public virtual void TestFuzziness()
+        {
+            RAMDirectory directory = new RAMDirectory();
+            IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true,
+                                                 IndexWriter.MaxFieldLength.LIMITED);
+            AddDoc("aaaaa", writer);
+            AddDoc("aaaab", writer);
+            AddDoc("aaabb", writer);
+            AddDoc("aabbb", writer);
+            AddDoc("abbbb", writer);
+            AddDoc("bbbbb", writer);
+            AddDoc("ddddd", writer);
+            writer.Optimize();
+            writer.Close();
+            IndexSearcher searcher = new IndexSearcher(directory, true);
+
+            FuzzyQuery query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 0);
+            ScoreDoc[] hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+
+            // same with prefix
+            query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 1);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+            query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 2);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+            query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 3);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+            query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 4);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(2, hits.Length);
+            query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 5);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(1, hits.Length);
+            query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 6);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(1, hits.Length);
+
+            // test scoring
+            query = new FuzzyQuery(new Term("field", "bbbbb"), FuzzyQuery.defaultMinSimilarity, 0);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length, "3 documents should match");
+            List<String> order = new List<string>(new[] {"bbbbb", "abbbb", "aabbb"});
+            for (int i = 0; i < hits.Length; i++)
+            {
+                String term = searcher.Doc(hits[i].doc).Get("field");
+                //System.out.println(hits[i].score);
+                Assert.AreEqual(order[i], term);
+            }
+
+            // test BooleanQuery.maxClauseCount
+            int savedClauseCount = BooleanQuery.GetMaxClauseCount();
+            try
+            {
+                BooleanQuery.SetMaxClauseCount(2);
+                // This query would normally return 3 documents, because 3 terms match (see above):
+                query = new FuzzyQuery(new Term("field", "bbbbb"), FuzzyQuery.defaultMinSimilarity, 0);
+                hits = searcher.Search(query, null, 1000).ScoreDocs;
+                Assert.AreEqual(2, hits.Length, "only 2 documents should match");
+                order = new List<string>(new[] {"bbbbb", "abbbb"});
+                for (int i = 0; i < hits.Length; i++)
+                {
+                    String term = searcher.Doc(hits[i].doc).Get("field");
+                    //System.out.println(hits[i].score);
+                    Assert.AreEqual(order[i], term);
+                }
+            }
+            finally
+            {
+                BooleanQuery.SetMaxClauseCount(savedClauseCount);
+            }
+
+            // not similar enough:
+            query = new FuzzyQuery(new Term("field", "xxxxx"), FuzzyQuery.defaultMinSimilarity, 0);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(0, hits.Length);
+            query = new FuzzyQuery(new Term("field", "aaccc"), FuzzyQuery.defaultMinSimilarity, 0);
+                // edit distance to "aaaaa" = 3
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(0, hits.Length);
+
+            // query identical to a word in the index:
+            query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 0);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
+            // default allows for up to two edits:
+            Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
+            Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
+
+            // query similar to a word in the index:
+            query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 0);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
+            Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
+            Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
+
+            // now with prefix
+            query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 1);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
+            Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
+            Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
+            query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 2);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
+            Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
+            Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
+            query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 3);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(3, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
+            Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
+            Assert.AreEqual(searcher.Doc(hits[2].doc).Get("field"), ("aaabb"));
+            query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 4);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(2, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("aaaaa"));
+            Assert.AreEqual(searcher.Doc(hits[1].doc).Get("field"), ("aaaab"));
+            query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 5);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(0, hits.Length);
+
+
+            query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 0);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(1, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
+
+            // now with prefix
+            query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 1);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(1, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
+            query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 2);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(1, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
+            query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 3);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(1, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
+            query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 4);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(1, hits.Length);
+            Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), ("ddddd"));
+            query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 5);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(0, hits.Length);
+
+
+            // different field = no match:
+            query = new FuzzyQuery(new Term("anotherfield", "ddddX"), FuzzyQuery.defaultMinSimilarity, 0);
+            hits = searcher.Search(query, null, 1000).ScoreDocs;
+            Assert.AreEqual(0, hits.Length);
+
+            searcher.Close();
+            directory.Close();
+        }
+
+	    [Test]
 		public virtual void  TestFuzzinessLong()
 		{
 			RAMDirectory directory = new RAMDirectory();
@@ -181,7 +217,7 @@ namespace Lucene.Net.Search
 			AddDoc("segment", writer);
 			writer.Optimize();
 			writer.Close();
-			IndexSearcher searcher = new IndexSearcher(directory);
+	        IndexSearcher searcher = new IndexSearcher(directory, true);
 			
 			FuzzyQuery query;
 			// not similar enough:
@@ -277,7 +313,7 @@ namespace Lucene.Net.Search
 			AddDoc("segment", writer);
 			writer.Optimize();
 			writer.Close();
-			IndexSearcher searcher = new IndexSearcher(directory);
+		    IndexSearcher searcher = new IndexSearcher(directory, true);
 			
 			Query query;
 			// term not over 10 chars, so optimization shortcuts
@@ -305,7 +341,7 @@ namespace Lucene.Net.Search
 		public virtual void  TestGiga()
 		{
 			
-			StandardAnalyzer analyzer = new StandardAnalyzer();
+			StandardAnalyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
 			
 			Directory index = new MockRAMDirectory();
 			IndexWriter w = new IndexWriter(index, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
@@ -330,7 +366,7 @@ namespace Lucene.Net.Search
 			IndexReader r = w.GetReader();
 			w.Close();
 			
-			Query q = new QueryParser("field", analyzer).Parse("giga~0.9");
+			Query q = new QueryParser(Util.Version.LUCENE_CURRENT, "field", analyzer).Parse("giga~0.9");
 			
 			// 3. search
 			IndexSearcher searcher = new IndexSearcher(r);

Modified: incubator/lucene.net/trunk/test/core/Search/TestMatchAllDocsQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestMatchAllDocsQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestMatchAllDocsQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestMatchAllDocsQuery.cs Tue Feb 28 22:43:08 2012
@@ -61,8 +61,8 @@ namespace Lucene.Net.Search
 			AddDoc("two", iw, 20f);
 			AddDoc("three four", iw, 300f);
 			iw.Close();
-			
-			IndexReader ir = IndexReader.Open(dir);
+
+		    IndexReader ir = IndexReader.Open(dir, false);
 			IndexSearcher is_Renamed = new IndexSearcher(ir);
 			ScoreDoc[] hits;
 			
@@ -114,7 +114,7 @@ namespace Lucene.Net.Search
 			Assert.AreEqual(2, hits.Length);
 			
 			// test parsable toString()
-			QueryParser qp = new QueryParser("key", analyzer);
+			QueryParser qp = new QueryParser(Util.Version.LUCENE_CURRENT, "key", analyzer);
 			hits = is_Renamed.Search(qp.Parse(new MatchAllDocsQuery().ToString()), null, 1000).ScoreDocs;
 			Assert.AreEqual(2, hits.Length);
 			

Modified: incubator/lucene.net/trunk/test/core/Search/TestMultiPhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestMultiPhraseQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestMultiPhraseQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestMultiPhraseQuery.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using System.Collections.Generic;
 using NUnit.Framework;
 
 using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
@@ -33,12 +33,7 @@ using LuceneTestCase = Lucene.Net.Util.L
 namespace Lucene.Net.Search
 {
 	
-	/// <summary> This class tests the MultiPhraseQuery class.
-	/// 
-	/// 
-	/// </summary>
-	/// <version>  $Id: TestMultiPhraseQuery.java 794078 2009-07-14 21:39:22Z markrmiller $
-	/// </version>
+	/// <summary>This class tests the MultiPhraseQuery class.</summary>
     [TestFixture]
 	public class TestMultiPhraseQuery:LuceneTestCase
 	{
@@ -57,8 +52,8 @@ namespace Lucene.Net.Search
 			Add("piccadilly circus", writer);
 			writer.Optimize();
 			writer.Close();
-			
-			IndexSearcher searcher = new IndexSearcher(indexStore);
+
+		    IndexSearcher searcher = new IndexSearcher(indexStore, true);
 			
 			// search for "blueberry pi*":
 			MultiPhraseQuery query1 = new MultiPhraseQuery();
@@ -68,7 +63,7 @@ namespace Lucene.Net.Search
 			query2.Add(new Term("body", "strawberry"));
 			
 			System.Collections.ArrayList termsWithPrefix = new System.Collections.ArrayList();
-			IndexReader ir = IndexReader.Open(indexStore);
+		    IndexReader ir = IndexReader.Open(indexStore, true);
 			
 			// this TermEnum gives "piccadilly", "pie" and "pizza".
 			System.String prefix = "pi";
@@ -156,8 +151,8 @@ namespace Lucene.Net.Search
 			Add("blue raspberry pie", writer);
 			writer.Optimize();
 			writer.Close();
-			
-			IndexSearcher searcher = new IndexSearcher(indexStore);
+
+		    IndexSearcher searcher = new IndexSearcher(indexStore, true);
 			// This query will be equivalent to +body:pie +body:"blue*"
 			BooleanQuery q = new BooleanQuery();
 			q.Add(new TermQuery(new Term("body", "pie")), BooleanClause.Occur.MUST);
@@ -177,12 +172,12 @@ namespace Lucene.Net.Search
 		public virtual void  TestPhrasePrefixWithBooleanQuery()
 		{
 			RAMDirectory indexStore = new RAMDirectory();
-			IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(new System.Collections.Hashtable(0)), true, IndexWriter.MaxFieldLength.LIMITED);
+			IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(Util.Version.LUCENE_CURRENT, new HashSet<string>()), true, IndexWriter.MaxFieldLength.LIMITED);
 			Add("This is a test", "object", writer);
 			Add("a note", "note", writer);
 			writer.Close();
-			
-			IndexSearcher searcher = new IndexSearcher(indexStore);
+
+		    IndexSearcher searcher = new IndexSearcher(indexStore, true);
 			
 			// This query will be equivalent to +type:note +body:"a t*"
 			BooleanQuery q = new BooleanQuery();

Modified: incubator/lucene.net/trunk/test/core/Search/TestMultiSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestMultiSearcher.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestMultiSearcher.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestMultiSearcher.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,8 @@
  */
 
 using System;
-
+using System.Collections.Generic;
+using Lucene.Net.Support;
 using NUnit.Framework;
 
 using KeywordAnalyzer = Lucene.Net.Analysis.KeywordAnalyzer;
@@ -36,11 +37,7 @@ using LuceneTestCase = Lucene.Net.Util.L
 namespace Lucene.Net.Search
 {
 	
-	/// <summary> Tests {@link MultiSearcher} class.
-	/// 
-	/// </summary>
-	/// <version>  $Id: TestMultiSearcher.java 781130 2009-06-02 19:16:20Z mikemccand $
-	/// </version>
+	/// <summary>Tests {@link MultiSearcher} class.</summary>
     [TestFixture]
 	public class TestMultiSearcher:LuceneTestCase
 	{
@@ -125,9 +122,9 @@ namespace Lucene.Net.Search
 			lDoc3.Add(new Field("handle", "1", Field.Store.YES, Field.Index.NOT_ANALYZED));
 			
 			// creating an index writer for the first index
-			IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+			IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), 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(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
 			
 			//--------------------------------------------------------------------
 			// scenario 1
@@ -144,14 +141,14 @@ namespace Lucene.Net.Search
 			writerB.Close();
 			
 			// creating the query
-			QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer());
+			QueryParser parser = new QueryParser(Util.Version.LUCENE_CURRENT, "fulltext", new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Query query = parser.Parse("handle:1");
 			
 			// building the searchables
 			Searcher[] searchers = new Searcher[2];
 			// VITAL STEP:adding the searcher for the empty index first, before the searcher for the populated index
-			searchers[0] = new IndexSearcher(indexStoreB);
-			searchers[1] = new IndexSearcher(indexStoreA);
+			searchers[0] = new IndexSearcher(indexStoreB, true);
+			searchers[1] = new IndexSearcher(indexStoreA, true);
 			// creating the multiSearcher
 			Searcher mSearcher = GetMultiSearcherInstance(searchers);
 			// performing the search
@@ -172,7 +169,7 @@ namespace Lucene.Net.Search
 			//--------------------------------------------------------------------
 			
 			// adding one document to the empty index
-			writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+			writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
 			writerB.AddDocument(lDoc);
 			writerB.Optimize();
 			writerB.Close();
@@ -180,8 +177,8 @@ namespace Lucene.Net.Search
 			// building the searchables
 			Searcher[] searchers2 = new Searcher[2];
 			// VITAL STEP:adding the searcher for the empty index first, before the searcher for the populated index
-			searchers2[0] = new IndexSearcher(indexStoreB);
-			searchers2[1] = new IndexSearcher(indexStoreA);
+			searchers2[0] = new IndexSearcher(indexStoreB, true);
+			searchers2[1] = new IndexSearcher(indexStoreA, true);
 			// creating the mulitSearcher
 			MultiSearcher mSearcher2 = GetMultiSearcherInstance(searchers2);
 			// performing the same search
@@ -214,20 +211,20 @@ namespace Lucene.Net.Search
 			
 			// deleting the document just added, this will cause a different exception to take place
 			Term term = new Term("id", "doc1");
-			IndexReader readerB = IndexReader.Open(indexStoreB);
+		    IndexReader readerB = IndexReader.Open(indexStoreB, false);
 			readerB.DeleteDocuments(term);
 			readerB.Close();
 			
 			// optimizing the index with the writer
-			writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+			writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
 			writerB.Optimize();
 			writerB.Close();
 			
 			// building the searchables
 			Searcher[] searchers3 = new Searcher[2];
 			
-			searchers3[0] = new IndexSearcher(indexStoreB);
-			searchers3[1] = new IndexSearcher(indexStoreA);
+			searchers3[0] = new IndexSearcher(indexStoreB, true);
+			searchers3[1] = new IndexSearcher(indexStoreA, true);
 			// creating the mulitSearcher
 			Searcher mSearcher3 = GetMultiSearcherInstance(searchers3);
 			// performing the same search
@@ -295,8 +292,8 @@ namespace Lucene.Net.Search
 			InitIndex(ramDirectory1, 10, true, null); // documents with a single token "doc0", "doc1", etc...
 			InitIndex(ramDirectory2, 10, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
 			
-			indexSearcher1 = new IndexSearcher(ramDirectory1);
-			indexSearcher2 = new IndexSearcher(ramDirectory2);
+			indexSearcher1 = new IndexSearcher(ramDirectory1, true);
+			indexSearcher2 = new IndexSearcher(ramDirectory2, true);
 			
 			MultiSearcher searcher = GetMultiSearcherInstance(new Searcher[]{indexSearcher1, indexSearcher2});
 			Assert.IsTrue(searcher != null, "searcher is null and it shouldn't be");
@@ -308,9 +305,9 @@ namespace Lucene.Net.Search
 			Assert.IsTrue(document.GetFields().Count == 2, "document.getFields() Size: " + document.GetFields().Count + " is not: " + 2);
 			//Should be one document from each directory
 			//they both have two fields, contents and other
-			System.Collections.Hashtable ftl = new System.Collections.Hashtable();
-			SupportClass.CollectionsHelper.AddIfNotContains(ftl, "other");
-			SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, (System.Collections.Hashtable) new System.Collections.Hashtable());
+			ISet<string> ftl = new HashSet<string>();
+			ftl.Add("other");
+			SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, new HashSet<string>());
 			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);
@@ -319,8 +316,8 @@ namespace Lucene.Net.Search
 			value_Renamed = document.Get("other");
 			Assert.IsTrue(value_Renamed != null, "value is null and it shouldn't be");
 			ftl.Clear();
-			SupportClass.CollectionsHelper.AddIfNotContains(ftl, "contents");
-			fs = new SetBasedFieldSelector(ftl, (System.Collections.Hashtable) new System.Collections.Hashtable());
+			ftl.Add("contents");
+			fs = new SetBasedFieldSelector(ftl, new HashSet<string>());
 			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");
@@ -353,8 +350,8 @@ namespace Lucene.Net.Search
 			// First put the documents in the same index
 			InitIndex(ramDirectory1, nDocs, true, null); // documents with a single token "doc0", "doc1", etc...
 			InitIndex(ramDirectory1, nDocs, false, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
-			
-			indexSearcher1 = new IndexSearcher(ramDirectory1);
+
+		    indexSearcher1 = new IndexSearcher(ramDirectory1, true);
 			indexSearcher1.SetDefaultFieldSortScoring(true, true);
 			
 			hits = indexSearcher1.Search(query, null, 1000).ScoreDocs;
@@ -382,9 +379,9 @@ namespace Lucene.Net.Search
 			InitIndex(ramDirectory1, nDocs, true, null); // documents with a single token "doc0", "doc1", etc...
 			InitIndex(ramDirectory2, nDocs, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
 			
-			indexSearcher1 = new IndexSearcher(ramDirectory1);
+			indexSearcher1 = new IndexSearcher(ramDirectory1, true);
 			indexSearcher1.SetDefaultFieldSortScoring(true, true);
-			indexSearcher2 = new IndexSearcher(ramDirectory2);
+			indexSearcher2 = new IndexSearcher(ramDirectory2, true);
 			indexSearcher2.SetDefaultFieldSortScoring(true, true);
 			
 			Searcher searcher = GetMultiSearcherInstance(new Searcher[]{indexSearcher1, indexSearcher2});
@@ -420,7 +417,7 @@ namespace Lucene.Net.Search
 		{
 			RAMDirectory dir = new RAMDirectory();
 			InitIndex(dir, 10, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
-			IndexSearcher srchr = new IndexSearcher(dir);
+		    IndexSearcher srchr = new IndexSearcher(dir, true);
 			MultiSearcher msrchr = GetMultiSearcherInstance(new Searcher[]{srchr});
 			
 			Similarity customSimilarity = new AnonymousClassDefaultSimilarity(this);
@@ -440,7 +437,22 @@ namespace Lucene.Net.Search
 			
 			// The scores from the IndexSearcher and Multisearcher should be the same
 			// if the same similarity is used.
-			Assert.AreEqual(score1, scoreN, 1e-6, "MultiSearcher score must be equal to single esrcher score!");
+			Assert.AreEqual(score1, scoreN, 1e-6, "MultiSearcher score must be equal to single searcher score!");
 		}
+
+        public void TestDocFreq()
+        {
+            RAMDirectory dir1 = new RAMDirectory();
+            RAMDirectory dir2 = new RAMDirectory();
+
+            InitIndex(dir1, 10, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
+            InitIndex(dir2, 5, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
+            IndexSearcher searcher1 = new IndexSearcher(dir1, true);
+            IndexSearcher searcher2 = new IndexSearcher(dir2, true);
+
+            MultiSearcher multiSearcher = GetMultiSearcherInstance(new Searcher[] { searcher1, searcher2 });
+            Assert.AreEqual(15, multiSearcher.DocFreq(new Term("contents", "x")));
+
+        }
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/test/core/Search/TestMultiSearcherRanking.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestMultiSearcherRanking.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestMultiSearcherRanking.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestMultiSearcherRanking.cs Tue Feb 28 22:43:08 2012
@@ -34,10 +34,7 @@ namespace Lucene.Net.Search
 	
 	/// <summary> Tests {@link MultiSearcher} ranking, i.e. makes sure this bug is fixed:
 	/// http://issues.apache.org/bugzilla/show_bug.cgi?id=31841
-	/// 
 	/// </summary>
-	/// <version>  $Id: TestMultiSearcher.java 150492 2004-09-06 22:01:49Z dnaber $
-	/// </version>
     [TestFixture]
 	public class TestMultiSearcherRanking:LuceneTestCase
 	{
@@ -109,7 +106,7 @@ namespace Lucene.Net.Search
 			// check result hit ranking
 			if (verbose)
 				System.Console.Out.WriteLine("Query: " + queryStr);
-			QueryParser queryParser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+			QueryParser queryParser = new QueryParser(Util.Version.LUCENE_CURRENT, FIELD_NAME, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
 			Query query = queryParser.Parse(queryStr);
 			ScoreDoc[] multiSearcherHits = multiSearcher.Search(query, null, 1000).ScoreDocs;
 			ScoreDoc[] singleSearcherHits = singleSearcher.Search(query, null, 1000).ScoreDocs;
@@ -136,26 +133,26 @@ namespace Lucene.Net.Search
 			base.SetUp();
 			// create MultiSearcher from two seperate searchers
 			Directory d1 = new RAMDirectory();
-			IndexWriter iw1 = new IndexWriter(d1, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+			IndexWriter iw1 = new IndexWriter(d1, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
 			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(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
 			AddCollection2(iw2);
 			iw2.Close();
 			
 			Searchable[] s = new Searchable[2];
-			s[0] = new IndexSearcher(d1);
-			s[1] = new IndexSearcher(d2);
+			s[0] = new IndexSearcher(d1, true);
+            s[1] = new IndexSearcher(d2, true);
 			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(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
 			AddCollection1(iw);
 			AddCollection2(iw);
 			iw.Close();
-			singleSearcher = new IndexSearcher(d);
+            singleSearcher = new IndexSearcher(d, true);
 		}
 		
 		private void  AddCollection1(IndexWriter iw)

Modified: incubator/lucene.net/trunk/test/core/Search/TestMultiTermConstantScore.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestMultiTermConstantScore.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestMultiTermConstantScore.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestMultiTermConstantScore.cs Tue Feb 28 22:43:08 2012
@@ -189,8 +189,8 @@ namespace Lucene.Net.Search
 		public virtual void  TestEqualScores()
 		{
 			// NOTE: uses index build in *this* setUp
-			
-			IndexReader reader = IndexReader.Open(small);
+
+            IndexReader reader = IndexReader.Open(small, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			ScoreDoc[] result;
@@ -219,8 +219,8 @@ namespace Lucene.Net.Search
 		public virtual void  TestBoost()
 		{
 			// NOTE: uses index build in *this* setUp
-			
-			IndexReader reader = IndexReader.Open(small);
+
+            IndexReader reader = IndexReader.Open(small, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			// test for correct application of query normalization
@@ -274,8 +274,8 @@ namespace Lucene.Net.Search
 		public virtual void  TestBooleanOrderUnAffected()
 		{
 			// NOTE: uses index build in *this* setUp
-			
-			IndexReader reader = IndexReader.Open(small);
+
+            IndexReader reader = IndexReader.Open(small, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			// first do a regular TermRangeQuery which uses term expansion so
@@ -306,8 +306,8 @@ namespace Lucene.Net.Search
 		public virtual void  TestRangeQueryId()
 		{
 			// NOTE: uses index build in *super* setUp
-			
-			IndexReader reader = IndexReader.Open(signedIndex.index);
+
+            IndexReader reader = IndexReader.Open(signedIndex.index, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			int medId = ((maxId - minId) / 2);
@@ -435,8 +435,8 @@ namespace Lucene.Net.Search
 		public virtual void  TestRangeQueryIdCollating()
 		{
 			// NOTE: uses index build in *super* setUp
-			
-			IndexReader reader = IndexReader.Open(signedIndex.index);
+
+            IndexReader reader = IndexReader.Open(signedIndex.index, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			int medId = ((maxId - minId) / 2);
@@ -520,8 +520,8 @@ namespace Lucene.Net.Search
 		public virtual void  TestRangeQueryRand()
 		{
 			// NOTE: uses index build in *super* setUp
-			
-			IndexReader reader = IndexReader.Open(signedIndex.index);
+
+            IndexReader reader = IndexReader.Open(signedIndex.index, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			System.String minRP = Pad(signedIndex.minR);
@@ -585,7 +585,7 @@ namespace Lucene.Net.Search
 			// NOTE: uses index build in *super* setUp
 			
 			// using the unsigned index because collation seems to ignore hyphens
-			IndexReader reader = IndexReader.Open(unsignedIndex.index);
+            IndexReader reader = IndexReader.Open(unsignedIndex.index, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			System.String minRP = Pad(unsignedIndex.minR);
@@ -659,8 +659,8 @@ namespace Lucene.Net.Search
 			
 			writer.Optimize();
 			writer.Close();
-			
-			IndexReader reader = IndexReader.Open(farsiIndex);
+
+            IndexReader reader = IndexReader.Open(farsiIndex, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			// Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
@@ -695,14 +695,14 @@ namespace Lucene.Net.Search
 			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));
+				doc.Add(new Field("content", words[docnum], 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(danishIndex);
+
+            IndexReader reader = IndexReader.Open(danishIndex, true);
 			IndexSearcher search = new IndexSearcher(reader);
 			
 			System.Globalization.CompareInfo c = new System.Globalization.CultureInfo("da" + "-" + "dk").CompareInfo;

Modified: incubator/lucene.net/trunk/test/core/Search/TestMultiThreadTermVectors.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestMultiThreadTermVectors.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestMultiThreadTermVectors.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestMultiThreadTermVectors.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Support;
 using NUnit.Framework;
 
 using SimpleAnalyzer = Lucene.Net.Analysis.SimpleAnalyzer;
@@ -30,10 +30,6 @@ using LuceneTestCase = Lucene.Net.Util.L
 
 namespace Lucene.Net.Search
 {
-	
-	/// <summary> </summary>
-	/// <version>  $rcs = ' $Id: TestMultiThreadTermVectors.java 759556 2009-03-28 19:10:55Z mikemccand $ ' ;
-	/// </version>
     [TestFixture]
 	public class TestMultiThreadTermVectors:LuceneTestCase
 	{
@@ -66,7 +62,7 @@ namespace Lucene.Net.Search
 			
 			try
 			{
-				reader = IndexReader.Open(directory);
+			    reader = IndexReader.Open(directory, true);
 				for (int i = 1; i <= numThreads; i++)
 					TestTermPositionVectors(reader, i);
 			}
@@ -135,7 +131,7 @@ namespace Lucene.Net.Search
 	{
 		
 		private IndexReader reader = null;
-		private SupportClass.ThreadClass t = null;
+		private ThreadClass t = null;
 		
 		private int runsToDo = 100;
 		internal long timeElapsed = 0;
@@ -145,7 +141,7 @@ namespace Lucene.Net.Search
 		{
 			this.reader = reader;
 			timeElapsed = 0;
-			t = new SupportClass.ThreadClass(new System.Threading.ThreadStart(this.Run));
+			t = new ThreadClass(new System.Threading.ThreadStart(this.Run));
 			t.Start();
 		}
 		

Modified: incubator/lucene.net/trunk/test/core/Search/TestMultiValuedNumericRangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestMultiValuedNumericRangeQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestMultiValuedNumericRangeQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestMultiValuedNumericRangeQuery.cs Tue Feb 28 22:43:08 2012
@@ -74,9 +74,7 @@ namespace Lucene.Net.Search
 					int a = lower; lower = upper; upper = a;
 				}
 				TermRangeQuery cq = new TermRangeQuery("asc", lower.ToString().PadLeft(11, '0'),  upper.ToString().PadLeft(11, '0'), true, true);
-				System.Int32 tempAux = (System.Int32) lower;
-				System.Int32 tempAux2 = (System.Int32) upper;
-				NumericRangeQuery tq = NumericRangeQuery.NewIntRange("trie", tempAux, tempAux2, true, true);
+                NumericRangeQuery<int> tq = NumericRangeQuery.NewIntRange("trie", lower, upper, 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");

Modified: incubator/lucene.net/trunk/test/core/Search/TestNot.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestNot.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestNot.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestNot.cs Tue Feb 28 22:43:08 2012
@@ -30,12 +30,7 @@ using LuceneTestCase = Lucene.Net.Util.L
 namespace Lucene.Net.Search
 {
 	
-	/// <summary>Similarity unit test.
-	/// 
-	/// 
-	/// </summary>
-	/// <version>  $Revision: 694004 $
-	/// </version>
+	/// <summary>Similarity unit test.</summary>
     [TestFixture]
 	public class TestNot:LuceneTestCase
 	{		
@@ -52,8 +47,8 @@ namespace Lucene.Net.Search
 			writer.Optimize();
 			writer.Close();
 			
-			Searcher searcher = new IndexSearcher(store);
-			QueryParser parser = new QueryParser("field", new SimpleAnalyzer());
+			Searcher searcher = new IndexSearcher(store, true);
+			QueryParser parser = new QueryParser(Util.Version.LUCENE_CURRENT, "field", new SimpleAnalyzer());
 			Query query = parser.Parse("a NOT b");
 			//System.out.println(query);
 			ScoreDoc[] hits = searcher.Search(query, null, 1000).ScoreDocs;

Modified: incubator/lucene.net/trunk/test/core/Search/TestNumericRangeQuery32.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestNumericRangeQuery32.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestNumericRangeQuery32.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestNumericRangeQuery32.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Index;
 using NUnit.Framework;
 
 using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
@@ -53,10 +53,10 @@ namespace Lucene.Net.Search
 			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);
+			NumericRangeQuery<int> 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);
+            NumericRangeFilter<int> f = NumericRangeFilter.NewIntRange(field, precisionStep, tempAux3, tempAux4, true, true);
 			int lastTerms = 0;
 			for (sbyte i = 0; i < 3; i++)
 			{
@@ -131,7 +131,7 @@ namespace Lucene.Net.Search
 		{
 			System.Int32 tempAux = 1000;
 			System.Int32 tempAux2 = - 1000;
-			NumericRangeFilter f = NumericRangeFilter.NewIntRange("field8", 8, tempAux, tempAux2, true, true);
+            NumericRangeFilter<int> 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;
@@ -148,7 +148,7 @@ namespace Lucene.Net.Search
 		{
 			System.Int32 tempAux = 1000;
 			System.Int32 tempAux2 = 1000;
-			NumericRangeQuery q = NumericRangeQuery.NewIntRange("ascfield8", 8, tempAux, tempAux2, true, true);
+            NumericRangeQuery<int> q = NumericRangeQuery.NewIntRange("ascfield8", 8, tempAux, tempAux2, true, true);
 			Assert.AreSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.GetRewriteMethod());
 			TopDocs topDocs = searcher.Search(q, noDocs);
 			ScoreDoc[] sd = topDocs.ScoreDocs;
@@ -163,7 +163,7 @@ namespace Lucene.Net.Search
 			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);
+            NumericRangeQuery<int> 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;
@@ -198,9 +198,7 @@ namespace Lucene.Net.Search
 			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);
+            NumericRangeQuery<int> q = NumericRangeQuery.NewIntRange(field, precisionStep, lower, 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;
@@ -246,7 +244,7 @@ namespace Lucene.Net.Search
 				// 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);
+                NumericRangeQuery<int> 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);
@@ -469,67 +467,82 @@ namespace Lucene.Net.Search
         [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("test1", 4, 10, 20, true, true));
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test2", 4, 10, 20, false, true));
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test3", 4, 10, 20, true, false));
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test4", 4, 10, 20, false, false));
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test5", 4, 10, null, true, true));
+			QueryUtils.CheckHashEquals(NumericRangeQuery.NewIntRange("test6", 4, null, 20, true, true));
 			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));
+            QueryUtils.CheckEqual(NumericRangeQuery.NewIntRange("test8", 4, 10, 20, true, true),
+                                  NumericRangeQuery.NewIntRange("test8", 4, 10, 20, true, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test9", 4, 10, 20, true, true),
+                                    NumericRangeQuery.NewIntRange("test9", 8, 10, 20, true, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test10a", 4, 10, 20, true, true),
+                                    NumericRangeQuery.NewIntRange("test10b", 4, 10, 20, true, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test11", 4, 10, 20, true, true),
+                                    NumericRangeQuery.NewIntRange("test11", 4, 20, 10, true, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test12", 4, 10, 20, true, true),
+                                    NumericRangeQuery.NewIntRange("test12", 4, 10, 20, false, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewIntRange("test13", 4, 10, 20, true, true),
+                                    NumericRangeQuery.NewFloatRange("test13", 4, 10f, 20f, 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);
+
+			Query q1 = NumericRangeQuery.NewIntRange("test14", 4, 10, 20, true, true);
+			Query q2 = NumericRangeQuery.NewLongRange("test14", 4, 10L, 20L, true, true);
 			Assert.IsFalse(q1.Equals(q2));
 			Assert.IsFalse(q2.Equals(q1));
 		}
-		static TestNumericRangeQuery32()
+
+
+        private void testEnum(int lower, int upper)
+        {
+            NumericRangeQuery<int> q = NumericRangeQuery.NewIntRange("field4", 4, lower, upper, true, true);
+            FilteredTermEnum termEnum = q.GetEnum(searcher.GetIndexReader());
+            try
+            {
+                int count = 0;
+                do
+                {
+                    Term t = termEnum.Term();
+                    if (t != null)
+                    {
+                        int val = NumericUtils.PrefixCodedToInt(t.Text());
+                        Assert.True(val >= lower && val <= upper, "value not in bounds");
+                        count++;
+                    }
+                    else break;
+                } while (termEnum.Next());
+                Assert.False(termEnum.Next());
+                Console.WriteLine("TermEnum on 'field4' for range [" + lower + "," + upper + "] contained " + count +
+                                  " terms.");
+            }
+            finally
+            {
+                termEnum.Close();
+            }
+        }
+
+        public void testEnum()
+        {
+            int count = 3000;
+            int lower = (distance*3/2) + startOffset, upper = lower + count*distance + (distance/3);
+            // test enum with values
+            testEnum(lower, upper);
+            // test empty enum
+            testEnum(upper, lower);
+            // test empty enum outside of bounds
+            lower = distance*noDocs + startOffset;
+            upper = 2*lower;
+            testEnum(lower, upper);
+        }
+
+        static TestNumericRangeQuery32()
 		{
 			{
 				try

Modified: incubator/lucene.net/trunk/test/core/Search/TestNumericRangeQuery64.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestNumericRangeQuery64.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestNumericRangeQuery64.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestNumericRangeQuery64.cs Tue Feb 28 22:43:08 2012
@@ -53,10 +53,10 @@ namespace Lucene.Net.Search
 			long lower = (distance * 3 / 2) + startOffset, upper = lower + count * distance + (distance / 3);
 			System.Int64 tempAux = (long) lower;
 			System.Int64 tempAux2 = (long) upper;
-			NumericRangeQuery q = NumericRangeQuery.NewLongRange(field, precisionStep, tempAux, tempAux2, true, true);
+			NumericRangeQuery<long> q = NumericRangeQuery.NewLongRange(field, precisionStep, tempAux, tempAux2, true, true);
 			System.Int64 tempAux3 = (long) lower;
 			System.Int64 tempAux4 = (long) upper;
-			NumericRangeFilter f = NumericRangeFilter.NewLongRange(field, precisionStep, tempAux3, tempAux4, true, true);
+            NumericRangeFilter<long> f = NumericRangeFilter.NewLongRange(field, precisionStep, tempAux3, tempAux4, true, true);
 			int lastTerms = 0;
 			for (sbyte i = 0; i < 3; i++)
 			{
@@ -137,7 +137,7 @@ namespace Lucene.Net.Search
 		{
 			System.Int64 tempAux = 1000L;
 			System.Int64 tempAux2 = - 1000L;
-			NumericRangeFilter f = NumericRangeFilter.NewLongRange("field8", 8, tempAux, tempAux2, true, true);
+            NumericRangeFilter<long> f = NumericRangeFilter.NewLongRange("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.Int64' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
 			System.Int64 tempAux3 = (long) System.Int64.MaxValue;
@@ -155,7 +155,7 @@ namespace Lucene.Net.Search
 			System.Int64 tempAux = 1000L;
 			//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
 			System.Int64 tempAux2 = 1000L;
-			NumericRangeQuery q = NumericRangeQuery.NewLongRange("ascfield8", 8, tempAux, tempAux2, true, true);
+            NumericRangeQuery<long> q = NumericRangeQuery.NewLongRange("ascfield8", 8, tempAux, tempAux2, true, true);
 			Assert.AreSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.GetRewriteMethod());
 			TopDocs topDocs = searcher.Search(q, noDocs);
 			ScoreDoc[] sd = topDocs.ScoreDocs;
@@ -170,7 +170,7 @@ namespace Lucene.Net.Search
 			long upper = (count - 1) * distance + (distance / 3) + startOffset;
 			//UPGRADE_TODO: The 'System.Int64' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
 			System.Int64 tempAux = (long) upper;
-			NumericRangeQuery q = NumericRangeQuery.NewLongRange(field, precisionStep, null, tempAux, true, true);
+            NumericRangeQuery<long> q = NumericRangeQuery.NewLongRange(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;
@@ -213,7 +213,7 @@ namespace Lucene.Net.Search
 			long lower = (count - 1) * distance + (distance / 3) + startOffset;
 			//UPGRADE_TODO: The 'System.Int64' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
 			System.Int64 tempAux = (long) lower;
-			NumericRangeQuery q = NumericRangeQuery.NewLongRange(field, precisionStep, tempAux, null, true, true);
+			NumericRangeQuery<long> q = NumericRangeQuery.NewLongRange(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;
@@ -265,7 +265,7 @@ namespace Lucene.Net.Search
 				// test inclusive range
 				System.Int64 tempAux = (long) lower;
 				System.Int64 tempAux2 = (long) upper;
-				NumericRangeQuery tq = NumericRangeQuery.NewLongRange(field, precisionStep, tempAux, tempAux2, true, true);
+                NumericRangeQuery<long> tq = NumericRangeQuery.NewLongRange(field, precisionStep, tempAux, tempAux2, true, true);
 				TermRangeQuery cq = new TermRangeQuery(field, NumericUtils.LongToPrefixCoded(lower), NumericUtils.LongToPrefixCoded(upper), true, true);
 				TopDocs tTopDocs = searcher.Search(tq, 1);
 				TopDocs cTopDocs = searcher.Search(cq, 1);
@@ -512,57 +512,32 @@ namespace Lucene.Net.Search
         [Test]
 		public virtual void  TestEqualsAndHash()
 		{
-			System.Int64 tempAux = 10L;
-			System.Int64 tempAux2 = 20L;
-			QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test1", 4, tempAux, tempAux2, true, true));
-			System.Int64 tempAux3 = 10L;
-			System.Int64 tempAux4 = 20L;
-			QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test2", 4, tempAux3, tempAux4, false, true));
-			System.Int64 tempAux5 = 10L;
-			System.Int64 tempAux6 = 20L;
-			QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test3", 4, tempAux5, tempAux6, true, false));
+            QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test1", 4, 10L, 20L, true, true));
+            QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test2", 4, 10L, 20L, false, true));
+            QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test3", 4, 10L, 20L, true, false));
 			System.Int64 tempAux7 = 10L;
-			System.Int64 tempAux8 = 20L;
-			QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test4", 4, tempAux7, tempAux8, false, false));
-			//UPGRADE_TODO: The 'System.Int64' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
-			System.Int64 tempAux9 = 10L;
-			QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test5", 4, tempAux9, null, true, true));
-			//UPGRADE_TODO: The 'System.Int64' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'"
-			System.Int64 tempAux10 = 20L;
-			QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test6", 4, null, tempAux10, true, true));
-			//UPGRADE_TODO: The 'System.Int64' 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.NewLongRange("test4", 4, 10L, 20L, false, false));
+            QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test5", 4, 10L, null, true, true));
+            QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test6", 4, null, 20L, true, true));
 			QueryUtils.CheckHashEquals(NumericRangeQuery.NewLongRange("test7", 4, null, null, true, true));
-			System.Int64 tempAux11 = 10L;
-			System.Int64 tempAux12 = 20L;
-			System.Int64 tempAux13 = 10L;
-			System.Int64 tempAux14 = 20L;
-			QueryUtils.CheckEqual(NumericRangeQuery.NewLongRange("test8", 4, tempAux11, tempAux12, true, true), NumericRangeQuery.NewLongRange("test8", 4, tempAux13, tempAux14, true, true));
-			System.Int64 tempAux15 = 10L;
-			System.Int64 tempAux16 = 20L;
-			System.Int64 tempAux17 = 10L;
-			System.Int64 tempAux18 = 20L;
-			QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test9", 4, tempAux15, tempAux16, true, true), NumericRangeQuery.NewLongRange("test9", 8, tempAux17, tempAux18, true, true));
-			System.Int64 tempAux19 = 10L;
-			System.Int64 tempAux20 = 20L;
-			System.Int64 tempAux21 = 10L;
-			System.Int64 tempAux22 = 20L;
-			QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test10a", 4, tempAux19, tempAux20, true, true), NumericRangeQuery.NewLongRange("test10b", 4, tempAux21, tempAux22, true, true));
-			System.Int64 tempAux23 = 10L;
-			System.Int64 tempAux24 = 20L;
-			System.Int64 tempAux25 = 20L;
-			System.Int64 tempAux26 = 10L;
-			QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test11", 4, tempAux23, tempAux24, true, true), NumericRangeQuery.NewLongRange("test11", 4, tempAux25, tempAux26, true, true));
-			System.Int64 tempAux27 = 10L;
-			System.Int64 tempAux28 = 20L;
-			System.Int64 tempAux29 = 10L;
-			System.Int64 tempAux30 = 20L;
-			QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test12", 4, tempAux27, tempAux28, true, true), NumericRangeQuery.NewLongRange("test12", 4, tempAux29, tempAux30, false, true));
-			System.Int64 tempAux31 = 10L;
-			System.Int64 tempAux32 = 20L;
-			System.Single tempAux33 = (float) 10f;
-			System.Single tempAux34 = (float) 20f;
-			QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test13", 4, tempAux31, tempAux32, true, true), NumericRangeQuery.NewFloatRange("test13", 4, tempAux33, tempAux34, true, true));
-			// difference to int range is tested in TestNumericRangeQuery32
+            QueryUtils.CheckEqual(NumericRangeQuery.NewLongRange("test8", 4, 10L, 20L, true, true),
+                                  NumericRangeQuery.NewLongRange("test8", 4, 10L, 20L, true, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test9", 4, 10L, 20L, true, true),
+                                    NumericRangeQuery.NewLongRange("test9", 8, 10L, 20L, true, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test10a", 4, 10L, 20L, true, true),
+                                    NumericRangeQuery.NewLongRange("test10b", 4, 10L, 20L, true, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test11", 4, 10L, 20L, true, true),
+                                    NumericRangeQuery.NewLongRange("test11", 4, 20L, 10L, true, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test12", 4, 10L, 20L, true, true),
+                                    NumericRangeQuery.NewLongRange("test12", 4, 10L, 20L, false, true));
+
+            QueryUtils.CheckUnequal(NumericRangeQuery.NewLongRange("test13", 4, 10L, 20L, true, true),
+                                    NumericRangeQuery.NewFloatRange("test13", 4, 10f, 20f, true, true));
+            // difference to int range is tested in TestNumericRangeQuery32
 		}
 		static TestNumericRangeQuery64()
 		{

Modified: incubator/lucene.net/trunk/test/core/Search/TestPhrasePrefixQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestPhrasePrefixQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestPhrasePrefixQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestPhrasePrefixQuery.cs Tue Feb 28 22:43:08 2012
@@ -32,12 +32,7 @@ using LuceneTestCase = Lucene.Net.Util.L
 namespace Lucene.Net.Search
 {
 	
-	/// <summary> This class tests PhrasePrefixQuery class.
-	/// 
-	/// 
-	/// </summary>
-	/// <version>  $Id: TestPhrasePrefixQuery.java 694004 2008-09-10 21:38:52Z mikemccand $
-	/// </version>
+	/// <summary>This class tests PhrasePrefixQuery class.</summary>
     [TestFixture]
 	public class TestPhrasePrefixQuery:LuceneTestCase
 	{
@@ -68,8 +63,8 @@ namespace Lucene.Net.Search
 			writer.AddDocument(doc5);
 			writer.Optimize();
 			writer.Close();
-			
-			IndexSearcher searcher = new IndexSearcher(indexStore);
+
+		    IndexSearcher searcher = new IndexSearcher(indexStore, true);
 			
 			//PhrasePrefixQuery query1 = new PhrasePrefixQuery();
 			MultiPhraseQuery query1 = new MultiPhraseQuery();
@@ -79,7 +74,7 @@ namespace Lucene.Net.Search
 			query2.Add(new Term("body", "strawberry"));
 			
 			System.Collections.ArrayList termsWithPrefix = new System.Collections.ArrayList();
-			IndexReader ir = IndexReader.Open(indexStore);
+		    IndexReader ir = IndexReader.Open(indexStore, true);
 			
 			// this TermEnum gives "piccadilly", "pie" and "pizza".
 			System.String prefix = "pi";

Modified: incubator/lucene.net/trunk/test/core/Search/TestPhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestPhraseQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestPhraseQuery.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestPhraseQuery.cs Tue Feb 28 22:43:08 2012
@@ -102,8 +102,8 @@ namespace Lucene.Net.Search
 			
 			writer.Optimize();
 			writer.Close();
-			
-			searcher = new IndexSearcher(directory);
+
+		    searcher = new IndexSearcher(directory, true);
 			query = new PhraseQuery();
 		}
 		
@@ -236,14 +236,14 @@ namespace Lucene.Net.Search
 		public virtual void  TestPhraseQueryWithStopAnalyzer()
 		{
 			RAMDirectory directory = new RAMDirectory();
-			StopAnalyzer stopAnalyzer = new StopAnalyzer();
+			StopAnalyzer stopAnalyzer = new StopAnalyzer(Util.Version.LUCENE_24);
 			IndexWriter writer = new IndexWriter(directory, stopAnalyzer, true, IndexWriter.MaxFieldLength.LIMITED);
 			Document doc = new Document();
 			doc.Add(new Field("field", "the stop words are here", Field.Store.YES, Field.Index.ANALYZED));
 			writer.AddDocument(doc);
 			writer.Close();
-			
-			IndexSearcher searcher = new IndexSearcher(directory);
+
+		    IndexSearcher searcher = new IndexSearcher(directory, true);
 			
 			// valid exact phrase query
 			PhraseQuery query = new PhraseQuery();
@@ -254,7 +254,7 @@ namespace Lucene.Net.Search
 			QueryUtils.Check(query, searcher);
 			
 			
-			// currently StopAnalyzer does not leave "holes", so this matches.
+			// StopAnalyzer as of 2.4 does not leave "holes", so this matches.
 			query = new PhraseQuery();
 			query.Add(new Term("field", "words"));
 			query.Add(new Term("field", "here"));
@@ -283,8 +283,8 @@ namespace Lucene.Net.Search
 			
 			writer.Optimize();
 			writer.Close();
-			
-			IndexSearcher searcher = new IndexSearcher(directory);
+
+		    IndexSearcher searcher = new IndexSearcher(directory, true);
 			
 			PhraseQuery phraseQuery = new PhraseQuery();
 			phraseQuery.Add(new Term("source", "marketing"));
@@ -320,8 +320,8 @@ namespace Lucene.Net.Search
 			
 			writer.Optimize();
 			writer.Close();
-			
-			searcher = new IndexSearcher(directory);
+
+		    searcher = new IndexSearcher(directory, true);
 			
 			termQuery = new TermQuery(new Term("contents", "woo"));
 			phraseQuery = new PhraseQuery();
@@ -372,8 +372,8 @@ namespace Lucene.Net.Search
 			
 			writer.Optimize();
 			writer.Close();
-			
-			Searcher searcher = new IndexSearcher(directory);
+
+		    Searcher searcher = new IndexSearcher(directory, true);
 			PhraseQuery query = new PhraseQuery();
 			query.Add(new Term("field", "firstname"));
 			query.Add(new Term("field", "lastname"));
@@ -394,9 +394,8 @@ namespace Lucene.Net.Search
 		[Test]
 		public virtual void  TestToString()
 		{
-			StopAnalyzer analyzer = new StopAnalyzer();
-			StopFilter.SetEnablePositionIncrementsDefault(true);
-			QueryParser qp = new QueryParser("field", analyzer);
+			StopAnalyzer analyzer = new StopAnalyzer(Util.Version.LUCENE_CURRENT);
+			QueryParser qp = new QueryParser(Util.Version.LUCENE_CURRENT, "field", analyzer);
 			qp.SetEnablePositionIncrements(true);
 			PhraseQuery q = (PhraseQuery) qp.Parse("\"this hi this is a test is\"");
 			Assert.AreEqual("field:\"? hi ? ? ? test\"", q.ToString());

Modified: incubator/lucene.net/trunk/test/core/Search/TestPositionIncrement.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/core/Search/TestPositionIncrement.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/test/core/Search/TestPositionIncrement.cs (original)
+++ incubator/lucene.net/trunk/test/core/Search/TestPositionIncrement.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,9 @@
  */
 
 using System;
-
+using System.Collections.Generic;
+using Lucene.Net.Analysis;
+using Lucene.Net.Util;
 using NUnit.Framework;
 
 using Analyzer = Lucene.Net.Analysis.Analyzer;
@@ -48,13 +50,8 @@ using SpanTermQuery = Lucene.Net.Search.
 namespace Lucene.Net.Search
 {
 	
-	/// <summary> Term position unit test.
-	/// 
-	/// 
-	/// </summary>
-	/// <version>  $Revision: 806844 $
-	/// </version>
-	public class TestPositionIncrement:BaseTokenStreamTestCase
+	/// <summary>Term position unit test.</summary>
+	public class TestPositionIncrement : LuceneTestCase
 	{
 		private class AnonymousClassAnalyzer:Analyzer
 		{
@@ -71,9 +68,9 @@ namespace Lucene.Net.Search
 				private void  InitBlock(AnonymousClassAnalyzer enclosingInstance)
 				{
 					this.enclosingInstance = enclosingInstance;
-					posIncrAtt = (PositionIncrementAttribute) AddAttribute(typeof(PositionIncrementAttribute));
-					termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
-					offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
+					posIncrAtt =  AddAttribute<PositionIncrementAttribute>();
+					termAtt =  AddAttribute<TermAttribute>();
+					offsetAtt =  AddAttribute<OffsetAttribute>();
 				}
 				private AnonymousClassAnalyzer enclosingInstance;
 				public AnonymousClassAnalyzer Enclosing_Instance
@@ -91,7 +88,12 @@ namespace Lucene.Net.Search
 				internal PositionIncrementAttribute posIncrAtt;
 				internal TermAttribute termAtt;
 				internal OffsetAttribute offsetAtt;
-				
+
+                protected override void Dispose(bool disposing)
+                {
+                    // do nothing
+                }
+
 				public override bool IncrementToken()
 				{
 					if (i == TOKENS.Length)
@@ -134,9 +136,9 @@ namespace Lucene.Net.Search
 			writer.AddDocument(d);
 			writer.Optimize();
 			writer.Close();
-			
-			
-			IndexSearcher searcher = new IndexSearcher(store);
+
+
+		    IndexSearcher searcher = new IndexSearcher(store, true);
 			
 			TermPositions pos = searcher.GetIndexReader().TermPositions(new Term("field", "1"));
 			pos.Next();
@@ -230,7 +232,7 @@ namespace Lucene.Net.Search
 			Assert.AreEqual(0, hits.Length);
 			
 			// should not find "1 2" because there is a gap of 1 in the index
-			QueryParser qp = new QueryParser("field", new StopWhitespaceAnalyzer(false));
+			QueryParser qp = new QueryParser(Util.Version.LUCENE_CURRENT, "field", new StopWhitespaceAnalyzer(false));
 			q = (PhraseQuery) qp.Parse("\"1 2\"");
 			hits = searcher.Search(q, null, 1000).ScoreDocs;
 			Assert.AreEqual(0, hits.Length);
@@ -253,7 +255,7 @@ namespace Lucene.Net.Search
 			Assert.AreEqual(0, hits.Length);
 			
 			// when both qp qnd stopFilter propagate increments, we should find the doc.
-			qp = new QueryParser("field", new StopWhitespaceAnalyzer(true));
+			qp = new QueryParser(Util.Version.LUCENE_CURRENT, "field", new StopWhitespaceAnalyzer(true));
 			qp.SetEnablePositionIncrements(true);
 			q = (PhraseQuery) qp.Parse("\"1 stop 2\"");
 			hits = searcher.Search(q, null, 1000).ScoreDocs;
@@ -271,117 +273,99 @@ namespace Lucene.Net.Search
 			public override TokenStream TokenStream(System.String fieldName, System.IO.TextReader reader)
 			{
 				TokenStream ts = a.TokenStream(fieldName, reader);
-				return new StopFilter(enablePositionIncrements, ts, new System.String[]{"stop"});
-			}
-		}
-		
-		[Test]
-		public virtual void  TestPayloadsPos0()
-		{
-			for (int x = 0; x < 2; x++)
-			{
-				Directory dir = new MockRAMDirectory();
-				IndexWriter writer = new IndexWriter(dir, new TestPayloadAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
-				if (x == 1)
-				{
-					writer.SetAllowMinus1Position();
-				}
-				Document doc = new Document();
-                System.IO.MemoryStream ms = new System.IO.MemoryStream();
-                System.IO.StreamWriter sw = new System.IO.StreamWriter(ms);
-                sw.Write("a a b c d e a f g h i j a b k k");
-                // flush to stream & reset it's position so it can be read
-                sw.Flush();
-                ms.Position = 0;
-                doc.Add(new Field("content", new System.IO.StreamReader(ms)));
-				writer.AddDocument(doc);
-				
-				IndexReader r = writer.GetReader();
-				
-				TermPositions tp = r.TermPositions(new Term("content", "a"));
-				int count = 0;
-				Assert.IsTrue(tp.Next());
-				// "a" occurs 4 times
-				Assert.AreEqual(4, tp.Freq());
-				int expected;
-				if (x == 1)
-				{
-					expected = System.Int32.MaxValue;
-				}
-				else
-				{
-					expected = 0;
-				}
-				Assert.AreEqual(expected, tp.NextPosition());
-				if (x == 1)
-				{
-					continue;
-				}
-				Assert.AreEqual(1, tp.NextPosition());
-				Assert.AreEqual(3, tp.NextPosition());
-				Assert.AreEqual(6, tp.NextPosition());
-				
-				// only one doc has "a"
-				Assert.IsFalse(tp.Next());
-				
-				IndexSearcher is_Renamed = new IndexSearcher(r);
-				
-				SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
-				SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
-				SpanQuery[] sqs = new SpanQuery[]{stq1, stq2};
-				SpanNearQuery snq = new SpanNearQuery(sqs, 30, false);
-				
-				count = 0;
-				bool sawZero = false;
-				//System.out.println("\ngetPayloadSpans test");
-				Lucene.Net.Search.Spans.Spans pspans = snq.GetSpans(is_Renamed.GetIndexReader());
-				while (pspans.Next())
-				{
-					//System.out.println(pspans.doc() + " - " + pspans.start() + " - "+ pspans.end());
-					System.Collections.Generic.ICollection<byte[]> payloads = pspans.GetPayload();
-					sawZero |= pspans.Start() == 0;
-					for (System.Collections.IEnumerator it = payloads.GetEnumerator(); it.MoveNext(); )
-					{
-						count++;
-						System.Object generatedAux2 = it.Current;
-						//System.out.println(new String((byte[]) it.next()));
-					}
-				}
-				Assert.AreEqual(5, count);
-				Assert.IsTrue(sawZero);
-				
-				//System.out.println("\ngetSpans test");
-				Lucene.Net.Search.Spans.Spans spans = snq.GetSpans(is_Renamed.GetIndexReader());
-				count = 0;
-				sawZero = false;
-				while (spans.Next())
-				{
-					count++;
-					sawZero |= spans.Start() == 0;
-					//System.out.println(spans.doc() + " - " + spans.start() + " - " + spans.end());
-				}
-				Assert.AreEqual(4, count);
-				Assert.IsTrue(sawZero);
-				
-				//System.out.println("\nPayloadSpanUtil test");
-				
-				sawZero = false;
-				PayloadSpanUtil psu = new PayloadSpanUtil(is_Renamed.GetIndexReader());
-				System.Collections.Generic.ICollection<byte[]> pls = psu.GetPayloadsForQuery(snq);
-				count = pls.Count;
-				for (System.Collections.IEnumerator it = pls.GetEnumerator(); it.MoveNext(); )
-				{
-					System.String s = new System.String(System.Text.UTF8Encoding.UTF8.GetChars((byte[]) it.Current));
-					//System.out.println(s);
-					sawZero |= s.Equals("pos: 0");
-				}
-				Assert.AreEqual(5, count);
-				Assert.IsTrue(sawZero);
-				writer.Close();
-				is_Renamed.GetIndexReader().Close();
-				dir.Close();
+			    return new StopFilter(enablePositionIncrements, ts, new CharArraySet(new List<string> {"stop"}, true));
 			}
 		}
+
+        [Test]
+        public virtual void TestPayloadsPos0()
+        {
+            Directory dir = new MockRAMDirectory();
+            IndexWriter writer = new IndexWriter(dir, new TestPayloadAnalyzer(), true,
+                                                 IndexWriter.MaxFieldLength.LIMITED);
+            Document doc = new Document();
+            System.IO.MemoryStream ms = new System.IO.MemoryStream();
+            System.IO.StreamWriter sw = new System.IO.StreamWriter(ms);
+            sw.Write("a a b c d e a f g h i j a b k k");
+            // flush to stream & reset it's position so it can be read
+            sw.Flush();
+            ms.Position = 0;
+            doc.Add(new Field("content", new System.IO.StreamReader(ms)));
+            writer.AddDocument(doc);
+
+            IndexReader r = writer.GetReader();
+
+            TermPositions tp = r.TermPositions(new Term("content", "a"));
+            int count = 0;
+            Assert.IsTrue(tp.Next());
+            // "a" occurs 4 times
+            Assert.AreEqual(4, tp.Freq());
+            int expected = 0;
+            Assert.AreEqual(expected, tp.NextPosition());
+            Assert.AreEqual(1, tp.NextPosition());
+            Assert.AreEqual(3, tp.NextPosition());
+            Assert.AreEqual(6, tp.NextPosition());
+
+            // only one doc has "a"
+            Assert.IsFalse(tp.Next());
+
+            IndexSearcher is_Renamed = new IndexSearcher(r);
+
+            SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
+            SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
+            SpanQuery[] sqs = new SpanQuery[] {stq1, stq2};
+            SpanNearQuery snq = new SpanNearQuery(sqs, 30, false);
+
+            count = 0;
+            bool sawZero = false;
+            //System.out.println("\ngetPayloadSpans test");
+            Lucene.Net.Search.Spans.Spans pspans = snq.GetSpans(is_Renamed.GetIndexReader());
+            while (pspans.Next())
+            {
+                //System.out.println(pspans.doc() + " - " + pspans.start() + " - "+ pspans.end());
+                System.Collections.Generic.ICollection<byte[]> payloads = pspans.GetPayload();
+                sawZero |= pspans.Start() == 0;
+                for (System.Collections.IEnumerator it = payloads.GetEnumerator(); it.MoveNext();)
+                {
+                    count++;
+                    System.Object generatedAux2 = it.Current;
+                    //System.out.println(new String((byte[]) it.next()));
+                }
+            }
+            Assert.AreEqual(5, count);
+            Assert.IsTrue(sawZero);
+
+            //System.out.println("\ngetSpans test");
+            Lucene.Net.Search.Spans.Spans spans = snq.GetSpans(is_Renamed.GetIndexReader());
+            count = 0;
+            sawZero = false;
+            while (spans.Next())
+            {
+                count++;
+                sawZero |= spans.Start() == 0;
+                //System.out.println(spans.doc() + " - " + spans.start() + " - " + spans.end());
+            }
+            Assert.AreEqual(4, count);
+            Assert.IsTrue(sawZero);
+
+            //System.out.println("\nPayloadSpanUtil test");
+
+            sawZero = false;
+            PayloadSpanUtil psu = new PayloadSpanUtil(is_Renamed.GetIndexReader());
+            System.Collections.Generic.ICollection<byte[]> pls = psu.GetPayloadsForQuery(snq);
+            count = pls.Count;
+            for (System.Collections.IEnumerator it = pls.GetEnumerator(); it.MoveNext();)
+            {
+                System.String s = new System.String(System.Text.UTF8Encoding.UTF8.GetChars((byte[]) it.Current));
+                //System.out.println(s);
+                sawZero |= s.Equals("pos: 0");
+            }
+            Assert.AreEqual(5, count);
+            Assert.IsTrue(sawZero);
+            writer.Close();
+            is_Renamed.GetIndexReader().Close();
+            dir.Close();
+        }
 	}
 	
 	class TestPayloadAnalyzer:Analyzer
@@ -411,9 +395,9 @@ namespace Lucene.Net.Search
 			this.fieldName = fieldName;
 			pos = 0;
 			i = 0;
-			posIncrAttr = (PositionIncrementAttribute) input.AddAttribute(typeof(PositionIncrementAttribute));
-			payloadAttr = (PayloadAttribute) input.AddAttribute(typeof(PayloadAttribute));
-			termAttr = (TermAttribute) input.AddAttribute(typeof(TermAttribute));
+			posIncrAttr =  input.AddAttribute<PositionIncrementAttribute>();
+			payloadAttr =  input.AddAttribute<PayloadAttribute>();
+			termAttr =  input.AddAttribute<TermAttribute>();
 		}
 		
 		public override bool IncrementToken()



Mime
View raw message