You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2011/11/15 09:41:46 UTC
[Lucene.Net] svn commit: r1202091 [4/6] - in
/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/core/
src/core/Index/ src/core/Search/ src/core/Store/ src/demo/Demo.Common/
test/core/ test/core/Analysis/ test/core/Index/ test/core/QueryParser/
test/core/Sea...
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriterMergePolicy.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriterMergePolicy.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriterMergePolicy.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriterMergePolicy.cs Tue Nov 15 08:41:44 2011
@@ -220,7 +220,7 @@ namespace Lucene.Net.Index
AddDoc(writer);
}
CheckInvariants(writer);
- Assert.AreEqual(10, writer.DocCount());
+ Assert.AreEqual(10, writer.MaxDoc());
writer.Close();
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriterMerging.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriterMerging.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriterMerging.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestIndexWriterMerging.cs Tue Nov 15 08:41:44 2011
@@ -62,7 +62,7 @@ namespace Lucene.Net.Index
Directory merged = new MockRAMDirectory();
- IndexWriter writer = new IndexWriter(merged, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(merged, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.SetMergeFactor(2);
writer.AddIndexes(new Directory[]{indexA, indexB});
@@ -98,7 +98,7 @@ namespace Lucene.Net.Index
private void FillIndex(Directory dir, int start, int numDocs)
{
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.SetMergeFactor(2);
writer.SetMaxBufferedDocs(2);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestMultiLevelSkipList.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestMultiLevelSkipList.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestMultiLevelSkipList.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestMultiLevelSkipList.cs Tue Nov 15 08:41:44 2011
@@ -112,7 +112,7 @@ namespace Lucene.Net.Index
protected internal PayloadFilter(TokenStream input):base(input)
{
- payloadAtt = (PayloadAttribute) AddAttribute(typeof(PayloadAttribute));
+ payloadAtt = AddAttribute<PayloadAttribute>();
}
public override bool IncrementToken()
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestNorms.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestNorms.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestNorms.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestNorms.cs Tue Nov 15 08:41:44 2011
@@ -88,7 +88,7 @@ namespace Lucene.Net.Index
{
base.SetUp();
similarityOne = new SimilarityOne(this);
- anlzr = new StandardAnalyzer();
+ anlzr = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
}
/// <summary> Test that norms values are preserved as the index is maintained.
@@ -107,7 +107,7 @@ namespace Lucene.Net.Index
}
// test with a single index: index1
- System.IO.FileInfo indexDir1 = new System.IO.FileInfo(System.IO.Path.Combine(tempDir, "lucenetestindex1"));
+ System.IO.DirectoryInfo indexDir1 = new System.IO.DirectoryInfo(System.IO.Path.Combine(tempDir, "lucenetestindex1"));
Directory dir1 = FSDirectory.Open(indexDir1);
norms = new System.Collections.ArrayList();
@@ -125,14 +125,14 @@ namespace Lucene.Net.Index
modifiedNorms = new System.Collections.ArrayList();
numDocNorms = 0;
- System.IO.FileInfo indexDir2 = new System.IO.FileInfo(System.IO.Path.Combine(tempDir, "lucenetestindex2"));
+ System.IO.DirectoryInfo indexDir2 = new System.IO.DirectoryInfo(System.IO.Path.Combine(tempDir, "lucenetestindex2"));
Directory dir2 = FSDirectory.Open(indexDir2);
CreateIndex(dir2);
DoTestNorms(dir2);
// add index1 and index2 to a third index: index3
- System.IO.FileInfo indexDir3 = new System.IO.FileInfo(System.IO.Path.Combine(tempDir, "lucenetestindex3"));
+ System.IO.DirectoryInfo indexDir3 = new System.IO.DirectoryInfo(System.IO.Path.Combine(tempDir, "lucenetestindex3"));
Directory dir3 = FSDirectory.Open(indexDir3);
CreateIndex(dir3);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestOmitTf.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestOmitTf.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestOmitTf.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestOmitTf.cs Tue Nov 15 08:41:44 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using Lucene.Net.Search;
using NUnit.Framework;
using Analyzer = Lucene.Net.Analysis.Analyzer;
@@ -38,8 +38,6 @@ using _TestUtil = Lucene.Net.Util._TestU
namespace Lucene.Net.Index
{
-
-
[TestFixture]
public class TestOmitTf:LuceneTestCase
{
@@ -203,6 +201,19 @@ namespace Lucene.Net.Index
}
}
+ private class AnonymousIDFExplanation : Explanation.IDFExplanation
+ {
+ public override float GetIdf()
+ {
+ return 1.0f;
+ }
+
+ public override string Explain()
+ {
+ return "Inexplicable";
+ }
+ }
+
[Serializable]
public class SimpleSimilarity:Similarity
{
@@ -224,10 +235,6 @@ namespace Lucene.Net.Index
{
return 2.0f;
}
- public override float Idf(System.Collections.ICollection terms, Searcher searcher)
- {
- return 1.0f;
- }
public override float Idf(int docFreq, int numDocs)
{
return 1.0f;
@@ -236,6 +243,10 @@ namespace Lucene.Net.Index
{
return 1.0f;
}
+ public override Search.Explanation.IDFExplanation IdfExplain(System.Collections.Generic.ICollection<Term> terms, Searcher searcher)
+ {
+ return new AnonymousIDFExplanation();
+ }
}
@@ -244,7 +255,7 @@ namespace Lucene.Net.Index
public virtual void TestOmitTermFreqAndPositions()
{
Directory ram = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(ram, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
Document d = new Document();
@@ -292,7 +303,7 @@ namespace Lucene.Net.Index
public virtual void TestMixedMerge()
{
Directory ram = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(ram, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.SetMaxBufferedDocs(3);
writer.SetMergeFactor(2);
@@ -347,7 +358,7 @@ namespace Lucene.Net.Index
public virtual void TestMixedRAM()
{
Directory ram = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(ram, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.SetMaxBufferedDocs(10);
writer.SetMergeFactor(2);
@@ -398,7 +409,7 @@ namespace Lucene.Net.Index
public virtual void TestNoPrxFile()
{
Directory ram = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(ram, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.SetMaxBufferedDocs(3);
writer.SetMergeFactor(2);
@@ -431,7 +442,7 @@ namespace Lucene.Net.Index
public virtual void TestBasic()
{
Directory dir = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(dir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.SetMergeFactor(2);
writer.SetMaxBufferedDocs(2);
@@ -464,7 +475,7 @@ namespace Lucene.Net.Index
/*
* Verify the index
*/
- Searcher searcher = new IndexSearcher(dir);
+ Searcher searcher = new IndexSearcher(dir, true);
searcher.SetSimilarity(new SimpleSimilarity());
Term a = new Term("noTf", term);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestParallelReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestParallelReader.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestParallelReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestParallelReader.cs Tue Nov 15 08:41:44 2011
@@ -118,7 +118,7 @@ namespace Lucene.Net.Index
// one document only:
Directory dir2 = new MockRAMDirectory();
- IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d3 = new Document();
d3.Add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
w2.AddDocument(d3);
@@ -170,13 +170,13 @@ namespace Lucene.Net.Index
Directory dir2 = GetDir2();
// add another document to ensure that the indexes are not optimized
- IndexWriter modifier = new IndexWriter(dir1, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter modifier = new IndexWriter(dir1, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
Document d = new Document();
d.Add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
modifier.AddDocument(d);
modifier.Close();
- modifier = new IndexWriter(dir2, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
d = new Document();
d.Add(new Field("f2", "v2", Field.Store.YES, Field.Index.ANALYZED));
modifier.AddDocument(d);
@@ -189,7 +189,7 @@ namespace Lucene.Net.Index
Assert.IsFalse(pr.IsOptimized());
pr.Close();
- modifier = new IndexWriter(dir1, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir1, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
modifier.Optimize();
modifier.Close();
@@ -201,7 +201,7 @@ namespace Lucene.Net.Index
pr.Close();
- modifier = new IndexWriter(dir2, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
modifier.Optimize();
modifier.Close();
@@ -257,7 +257,7 @@ namespace Lucene.Net.Index
private Searcher Single()
{
Directory dir = new MockRAMDirectory();
- IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d1 = new Document();
d1.Add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
d1.Add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
@@ -289,7 +289,7 @@ namespace Lucene.Net.Index
private Directory GetDir1()
{
Directory dir1 = new MockRAMDirectory();
- IndexWriter w1 = new IndexWriter(dir1, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w1 = new IndexWriter(dir1, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d1 = new Document();
d1.Add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
d1.Add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
@@ -305,7 +305,7 @@ namespace Lucene.Net.Index
private Directory GetDir2()
{
Directory dir2 = new RAMDirectory();
- IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d3 = new Document();
d3.Add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
d3.Add(new Field("f4", "v1", Field.Store.YES, Field.Index.ANALYZED));
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestPayloads.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestPayloads.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestPayloads.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestPayloads.cs Tue Nov 15 08:41:44 2011
@@ -214,7 +214,7 @@ namespace Lucene.Net.Index
PerformTest(dir);
// now use a FSDirectory and repeat same test
- System.IO.FileInfo dirName = _TestUtil.GetTempDir("test_payloads");
+ System.IO.DirectoryInfo dirName = _TestUtil.GetTempDir("test_payloads");
dir = FSDirectory.Open(dirName);
PerformTest(dir);
_TestUtil.RmDir(dirName);
@@ -520,7 +520,7 @@ namespace Lucene.Net.Index
this.data = data;
this.length = length;
this.offset = offset;
- payloadAtt = (PayloadAttribute) AddAttribute(typeof(PayloadAttribute));
+ payloadAtt = AddAttribute<PayloadAttribute>();
}
public override bool IncrementToken()
@@ -626,8 +626,8 @@ namespace Lucene.Net.Index
Enclosing_Instance.GenerateRandomData(payload);
term = pool.BytesToString(payload);
first = true;
- payloadAtt = (PayloadAttribute) AddAttribute(typeof(PayloadAttribute));
- termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+ payloadAtt = AddAttribute<PayloadAttribute>();
+ termAtt = AddAttribute<TermAttribute>();
}
public override bool IncrementToken()
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestSnapshotDeletionPolicy.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestSnapshotDeletionPolicy.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestSnapshotDeletionPolicy.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestSnapshotDeletionPolicy.cs Tue Nov 15 08:41:44 2011
@@ -106,7 +106,7 @@ namespace Lucene.Net.Index
[Test]
public virtual void TestSnapshotDeletionPolicy_Renamed()
{
- System.IO.FileInfo dir = new System.IO.FileInfo(System.IO.Path.Combine(AppSettings.Get("tempDir", ""), INDEX_PATH));
+ System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(System.IO.Path.Combine(AppSettings.Get("tempDir", ""), INDEX_PATH));
try
{
// Sometimes past test leaves the dir
@@ -131,7 +131,7 @@ namespace Lucene.Net.Index
Directory dir = new MockRAMDirectory();
SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
- IndexWriter writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp);
+ IndexWriter writer = new IndexWriter(dir, true, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), dp);
// Force frequent commits
writer.SetMaxBufferedDocs(2);
Document doc = new Document();
@@ -143,7 +143,7 @@ namespace Lucene.Net.Index
writer.Close();
CopyFiles(dir, cp);
- writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp);
+ writer = new IndexWriter(dir, true, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), dp);
CopyFiles(dir, cp);
for (int i = 0; i < 7; i++)
writer.AddDocument(doc);
@@ -151,7 +151,7 @@ namespace Lucene.Net.Index
writer.Close();
CopyFiles(dir, cp);
dp.Release();
- writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp);
+ writer = new IndexWriter(dir, true, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), dp);
writer.Close();
try
{
@@ -171,7 +171,7 @@ namespace Lucene.Net.Index
long stopTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) + 7000;
SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
- IndexWriter writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp);
+ IndexWriter writer = new IndexWriter(dir, true, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), dp);
// Force frequent commits
writer.SetMaxBufferedDocs(2);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTermVectorsReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTermVectorsReader.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTermVectorsReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTermVectorsReader.cs Tue Nov 15 08:41:44 2011
@@ -178,9 +178,9 @@ namespace Lucene.Net.Index
public MyTokenStream(TestTermVectorsReader enclosingInstance)
{
InitBlock(enclosingInstance);
- termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
- posIncrAtt = (PositionIncrementAttribute) AddAttribute(typeof(PositionIncrementAttribute));
- offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
+ termAtt = AddAttribute<TermAttribute>();
+ posIncrAtt = AddAttribute<PositionIncrementAttribute>();
+ offsetAtt = AddAttribute<OffsetAttribute>();
}
public override bool IncrementToken()
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTermdocPerf.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTermdocPerf.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTermdocPerf.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTermdocPerf.cs Tue Nov 15 08:41:44 2011
@@ -43,7 +43,7 @@ namespace Lucene.Net.Index
public RepeatingTokenStream(System.String val)
{
this.value_Renamed = val;
- this.termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+ this.termAtt = AddAttribute<TermAttribute>();
}
public override bool IncrementToken()
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestThreadedOptimize.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestThreadedOptimize.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestThreadedOptimize.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestThreadedOptimize.cs Tue Nov 15 08:41:44 2011
@@ -132,7 +132,7 @@ namespace Lucene.Net.Index
writer.SetMergeFactor(4);
//writer.setInfoStream(System.out);
- int docCount = writer.DocCount();
+ int docCount = writer.MaxDoc();
ThreadClass[] threads = new ThreadClass[NUM_THREADS];
@@ -155,7 +155,7 @@ namespace Lucene.Net.Index
// System.out.println("TEST: now index=" + writer.segString());
- Assert.AreEqual(expectedDocCount, writer.DocCount());
+ Assert.AreEqual(expectedDocCount, writer.MaxDoc());
if (!autoCommit)
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTransactionRollback.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTransactionRollback.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTransactionRollback.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestTransactionRollback.cs Tue Nov 15 08:41:44 2011
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
using Lucene.Net.Support;
using NUnit.Framework;
@@ -51,7 +52,7 @@ namespace Lucene.Net.Index
// System.out.println("Attempting to rollback to "+id);
System.String ids = "-" + id;
IndexCommit last = null;
- System.Collections.ICollection commits = IndexReader.ListCommits(dir);
+ var commits = IndexReader.ListCommits(dir);
for (System.Collections.IEnumerator iterator = commits.GetEnumerator(); iterator.MoveNext(); )
{
IndexCommit commit = (IndexCommit) iterator.Current;
@@ -89,7 +90,7 @@ namespace Lucene.Net.Index
private void CheckExpecteds(System.Collections.BitArray expecteds)
{
- IndexReader r = IndexReader.Open(dir);
+ IndexReader r = IndexReader.Open(dir, true);
//Perhaps not the most efficient approach but meets our needs here.
for (int i = 0; i < r.MaxDoc(); i++)
@@ -175,11 +176,11 @@ namespace Lucene.Net.Index
this.rollbackPoint = rollbackPoint;
}
- public virtual void OnCommit(System.Collections.IList commits)
+ public virtual void OnCommit<T>(IList<T> commits) where T : IndexCommit
{
}
-
- public virtual void OnInit(System.Collections.IList commits)
+
+ public virtual void OnInit<T>(IList<T> commits) where T : IndexCommit
{
for (System.Collections.IEnumerator iterator = commits.GetEnumerator(); iterator.MoveNext(); )
{
@@ -231,14 +232,14 @@ namespace Lucene.Net.Index
}
}
-
- public virtual void OnCommit(System.Collections.IList commits)
+
+ public virtual void OnCommit<T>(IList<T> commits) where T : IndexCommit
{
}
- public virtual void OnInit(System.Collections.IList commits)
+ public virtual void OnInit<T>(IList<T> commits) where T : IndexCommit
{
- ((IndexCommit) commits[commits.Count - 1]).Delete();
+ commits[commits.Count - 1].Delete();
}
}
@@ -250,7 +251,7 @@ namespace Lucene.Net.Index
// Unless you specify a prior commit point, rollback
// should not work:
new IndexWriter(dir, new WhitespaceAnalyzer(), new DeleteLastCommitPolicy(this), MaxFieldLength.UNLIMITED).Close();
- IndexReader r = IndexReader.Open(dir);
+ IndexReader r = IndexReader.Open(dir, true);
Assert.AreEqual(100, r.NumDocs());
r.Close();
}
@@ -276,10 +277,10 @@ namespace Lucene.Net.Index
}
}
- public virtual void OnCommit(System.Collections.IList commits)
+ public virtual void OnCommit<T>(IList<T> commits) where T : IndexCommit
{
}
- public virtual void OnInit(System.Collections.IList commits)
+ public virtual void OnInit<T>(IList<T> commits) where T : IndexCommit
{
}
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestWordlistLoader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestWordlistLoader.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestWordlistLoader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Index/TestWordlistLoader.cs Tue Nov 15 08:41:44 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using System.Collections.Generic;
using NUnit.Framework;
using WordlistLoader = Lucene.Net.Analysis.WordlistLoader;
@@ -33,9 +33,9 @@ namespace Lucene.Net.Index
public virtual void TestWordlistLoading()
{
System.String s = "ONE\n two \nthree";
- System.Collections.Hashtable wordSet1 = WordlistLoader.GetWordSet(new System.IO.StringReader(s));
+ var wordSet1 = WordlistLoader.GetWordSet(new System.IO.StringReader(s));
CheckSet(wordSet1);
- System.Collections.Hashtable wordSet2 = WordlistLoader.GetWordSet(new System.IO.StringReader(s));
+ var wordSet2 = WordlistLoader.GetWordSet(new System.IO.StringReader(s));
CheckSet(wordSet2);
}
@@ -43,14 +43,14 @@ namespace Lucene.Net.Index
public virtual void TestComments()
{
System.String s = "ONE\n two \nthree\n#comment";
- System.Collections.Hashtable wordSet1 = WordlistLoader.GetWordSet(new System.IO.StringReader(s), "#");
+ var wordSet1 = WordlistLoader.GetWordSet(new System.IO.StringReader(s), "#");
CheckSet(wordSet1);
Assert.IsFalse(wordSet1.Contains("#comment"));
Assert.IsFalse(wordSet1.Contains("comment"));
}
- private void CheckSet(System.Collections.Hashtable wordset)
+ private void CheckSet(HashSet<string> wordset)
{
Assert.AreEqual(3, wordset.Count);
Assert.IsTrue(wordset.Contains("ONE")); // case is not modified
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj Tue Nov 15 08:41:44 2011
@@ -434,6 +434,7 @@
<Compile Include="Store\TestLockFactory.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Store\TestMultiMMap.cs" />
<Compile Include="Store\TestRAMDirectory.cs" />
<Compile Include="Store\TestWindowsMMap.cs">
<SubType>Code</SubType>
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiAnalyzer.cs Tue Nov 15 08:41:44 2011
@@ -183,10 +183,10 @@ namespace Lucene.Net.QueryParsers
public TestFilter(TestMultiAnalyzer enclosingInstance, TokenStream in_Renamed):base(in_Renamed)
{
InitBlock(enclosingInstance);
- termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
- posIncrAtt = (PositionIncrementAttribute) AddAttribute(typeof(PositionIncrementAttribute));
- offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
- typeAtt = (TypeAttribute) AddAttribute(typeof(TypeAttribute));
+ termAtt = AddAttribute<TermAttribute>();
+ posIncrAtt = AddAttribute<PositionIncrementAttribute>();
+ offsetAtt = AddAttribute<OffsetAttribute>();
+ typeAtt = AddAttribute<TypeAttribute>();
}
public override bool IncrementToken()
@@ -284,8 +284,8 @@ namespace Lucene.Net.QueryParsers
public TestPosIncrementFilter(TestMultiAnalyzer enclosingInstance, TokenStream in_Renamed):base(in_Renamed)
{
InitBlock(enclosingInstance);
- termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
- posIncrAtt = (PositionIncrementAttribute) AddAttribute(typeof(PositionIncrementAttribute));
+ termAtt = AddAttribute<TermAttribute>();
+ posIncrAtt = AddAttribute<PositionIncrementAttribute>();
}
public override bool IncrementToken()
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiFieldQueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiFieldQueryParser.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiFieldQueryParser.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestMultiFieldQueryParser.cs Tue Nov 15 08:41:44 2011
@@ -75,7 +75,7 @@ namespace Lucene.Net.QueryParsers
public virtual void TestSimple()
{
System.String[] fields = new System.String[]{"b", "t"};
- MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer());
+ MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Query q = mfqp.Parse("one");
Assert.AreEqual("b:one t:one", q.ToString());
@@ -139,7 +139,7 @@ namespace Lucene.Net.QueryParsers
boosts["b"] = (float) 5;
boosts["t"] = (float) 10;
System.String[] fields = new System.String[]{"b", "t"};
- MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer(), boosts);
+ MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), boosts);
//Check for simple
@@ -167,25 +167,25 @@ namespace Lucene.Net.QueryParsers
{
System.String[] fields = new System.String[]{"b", "t"};
System.String[] queries = new System.String[]{"one", "two"};
- Query q = MultiFieldQueryParser.Parse(queries, fields, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.Parse(queries, fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("b:one t:two", q.ToString());
System.String[] queries2 = new System.String[]{"+one", "+two"};
- q = MultiFieldQueryParser.Parse(queries2, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse(queries2, fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("(+b:one) (+t:two)", q.ToString());
System.String[] queries3 = new System.String[]{"one", "+two"};
- q = MultiFieldQueryParser.Parse(queries3, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse(queries3, fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("b:one (+t:two)", q.ToString());
System.String[] queries4 = new System.String[]{"one +more", "+two"};
- q = MultiFieldQueryParser.Parse(queries4, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse(queries4, fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("(b:one +b:more) (+t:two)", q.ToString());
System.String[] queries5 = new System.String[]{"blah"};
try
{
- q = MultiFieldQueryParser.Parse(queries5, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse(queries5, fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.Fail();
}
catch (System.ArgumentException e)
@@ -210,16 +210,16 @@ namespace Lucene.Net.QueryParsers
{
System.String[] fields = new System.String[]{"b", "t"};
BooleanClause.Occur[] flags = new BooleanClause.Occur[]{BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- Query q = MultiFieldQueryParser.Parse("one", fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.Parse("one", fields, flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("+b:one -t:one", q.ToString());
- q = MultiFieldQueryParser.Parse("one two", fields, flags, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse("one two", fields, flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("+(b:one b:two) -(t:one t:two)", q.ToString());
try
{
BooleanClause.Occur[] flags2 = new BooleanClause.Occur[]{BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.Parse("blah", fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse("blah", fields, flags2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.Fail();
}
catch (System.ArgumentException e)
@@ -234,18 +234,18 @@ namespace Lucene.Net.QueryParsers
System.String[] fields = new System.String[]{"b", "t"};
//int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
BooleanClause.Occur[] flags = new BooleanClause.Occur[]{BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
+ MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
- Query q = MultiFieldQueryParser.Parse("one", fields, flags, new StandardAnalyzer()); //, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.Parse("one", fields, flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT)); //, fields, flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("+b:one -t:one", q.ToString());
- q = MultiFieldQueryParser.Parse("one two", fields, flags, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse("one two", fields, flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("+(b:one b:two) -(t:one t:two)", q.ToString());
try
{
BooleanClause.Occur[] flags2 = new BooleanClause.Occur[]{BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.Parse("blah", fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse("blah", fields, flags2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.Fail();
}
catch (System.ArgumentException e)
@@ -260,13 +260,13 @@ namespace Lucene.Net.QueryParsers
System.String[] queries = new System.String[]{"one", "two", "three"};
System.String[] fields = new System.String[]{"f1", "f2", "f3"};
BooleanClause.Occur[] flags = new BooleanClause.Occur[]{BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT, BooleanClause.Occur.SHOULD};
- Query q = MultiFieldQueryParser.Parse(queries, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.Parse(queries, fields, flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("+f1:one -f2:two f3:three", q.ToString());
try
{
BooleanClause.Occur[] flags2 = new BooleanClause.Occur[]{BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.Parse(queries, fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse(queries, fields, flags2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.Fail();
}
catch (System.ArgumentException e)
@@ -281,13 +281,13 @@ namespace Lucene.Net.QueryParsers
System.String[] queries = new System.String[]{"one", "two"};
System.String[] fields = new System.String[]{"b", "t"};
BooleanClause.Occur[] flags = new BooleanClause.Occur[]{BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- Query q = MultiFieldQueryParser.Parse(queries, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.Parse(queries, fields, flags, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.AreEqual("+b:one -t:two", q.ToString());
try
{
BooleanClause.Occur[] flags2 = new BooleanClause.Occur[]{BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.Parse(queries, fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.Parse(queries, fields, flags2, new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
Assert.Fail();
}
catch (System.ArgumentException e)
@@ -315,7 +315,7 @@ namespace Lucene.Net.QueryParsers
[Test]
public virtual void TestStopWordSearching()
{
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
Directory ramDir = new RAMDirectory();
IndexWriter iw = new IndexWriter(ramDir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
@@ -335,7 +335,7 @@ namespace Lucene.Net.QueryParsers
/// <summary> Return empty tokens for field "f1".</summary>
private class AnalyzerReturningNull:Analyzer
{
- internal StandardAnalyzer stdAnalyzer = new StandardAnalyzer();
+ internal StandardAnalyzer stdAnalyzer = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
public AnalyzerReturningNull()
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/QueryParser/TestQueryParser.cs Tue Nov 15 08:41:44 2011
@@ -130,8 +130,8 @@ namespace Lucene.Net.QueryParsers
/// </summary>
public QPTestFilter(TokenStream in_Renamed):base(in_Renamed)
{
- termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
- offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
+ termAtt = AddAttribute<TermAttribute>();
+ offsetAtt = AddAttribute<OffsetAttribute>();
}
internal bool inPhrase = false;
@@ -365,7 +365,7 @@ namespace Lucene.Net.QueryParsers
AssertQueryEquals("+(apple \"steve jobs\") -(foo bar baz)", null, "+(apple \"steve jobs\") -(foo bar baz)");
AssertQueryEquals("+title:(dog OR cat) -author:\"bob dole\"", null, "+(title:dog title:cat) -author:\"bob dole\"");
- QueryParser qp = new QueryParser("field", new StandardAnalyzer());
+ QueryParser qp = new QueryParser("field", new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
// make sure OR is the default:
Assert.AreEqual(QueryParser.OR_OPERATOR, qp.GetDefaultOperator());
qp.SetDefaultOperator(QueryParser.AND_OPERATOR);
@@ -401,7 +401,7 @@ namespace Lucene.Net.QueryParsers
AssertQueryEquals("term 1.0 1 2", null, "term");
AssertQueryEquals("term term1 term2", null, "term term term");
- Analyzer a = new StandardAnalyzer();
+ Analyzer a = new StandardAnalyzer(Util.Version.LUCENE_CURRENT);
AssertQueryEquals("3", a, "3");
AssertQueryEquals("term 1.0 1 2", a, "term 1.0 1 2");
AssertQueryEquals("term term1 term2", a, "term term1 term2");
@@ -897,7 +897,7 @@ namespace Lucene.Net.QueryParsers
q = qp.Parse("\"on\"^1.0");
Assert.IsNotNull(q);
- QueryParser qp2 = new QueryParser("field", new StandardAnalyzer());
+ QueryParser qp2 = new QueryParser("field", new StandardAnalyzer(Util.Version.LUCENE_CURRENT));
q = qp2.Parse("the^3");
// "the" is a stop word so the result is an empty query:
Assert.IsNotNull(q);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/QueryUtils.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/QueryUtils.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/QueryUtils.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/QueryUtils.cs Tue Nov 15 08:41:44 2011
@@ -30,9 +30,6 @@ using ReaderUtil = Lucene.Net.Util.Reade
namespace Lucene.Net.Search
{
-
-
-
public class QueryUtils
{
[Serializable]
@@ -46,31 +43,34 @@ namespace Lucene.Net.Search
private class AnonymousClassCollector:Collector
{
- public AnonymousClassCollector(int[] order, int[] opidx, int skip_op, Lucene.Net.Search.Scorer scorer, int[] sdoc, float maxDiff, Lucene.Net.Search.Query q, Lucene.Net.Search.IndexSearcher s)
+ public AnonymousClassCollector(int[] order, int[] opidx, int skip_op, IndexReader[] lastReader, float maxDiff, Query q, IndexSearcher s, int[] lastDoc)
{
- InitBlock(order, opidx, skip_op, scorer, sdoc, maxDiff, q, s);
+ InitBlock(order, opidx, skip_op, lastReader, maxDiff, q, s, lastDoc);
}
- private void InitBlock(int[] order, int[] opidx, int skip_op, Lucene.Net.Search.Scorer scorer, int[] sdoc, float maxDiff, Lucene.Net.Search.Query q, Lucene.Net.Search.IndexSearcher s)
+ private void InitBlock(int[] order, int[] opidx, int skip_op, IndexReader[] lastReader, float maxDiff, Query q, IndexSearcher s, int[] lastDoc)
{
this.order = order;
this.opidx = opidx;
+ this.lastDoc = lastDoc;
this.skip_op = skip_op;
this.scorer = scorer;
- this.sdoc = sdoc;
+ this.lastReader = lastReader;
this.maxDiff = maxDiff;
this.q = q;
this.s = s;
}
+
+ private Scorer sc;
+ private IndexReader reader;
+ private Scorer scorer;
private int[] order;
+ private int[] lastDoc;
private int[] opidx;
private int skip_op;
- private Lucene.Net.Search.Scorer scorer;
- private int[] sdoc;
private float maxDiff;
private Lucene.Net.Search.Query q;
private Lucene.Net.Search.IndexSearcher s;
- private int base_Renamed = 0;
- private Scorer sc;
+ private IndexReader[] lastReader;
public override void SetScorer(Scorer scorer)
{
@@ -79,25 +79,40 @@ namespace Lucene.Net.Search
public override void Collect(int doc)
{
- doc = doc + base_Renamed;
float score = sc.Score();
+ lastDoc[0] = doc;
try
{
+ if (scorer == null)
+ {
+ Weight w = q.Weight(s);
+ scorer = w.Scorer(reader, true, false);
+ }
int op = order[(opidx[0]++) % order.Length];
// System.out.println(op==skip_op ?
// "skip("+(sdoc[0]+1)+")":"next()");
- bool more = op == skip_op?scorer.Advance(sdoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS:scorer.NextDoc() != DocIdSetIterator.NO_MORE_DOCS;
- sdoc[0] = scorer.DocID();
+ bool more = op == skip_op
+ ? scorer.Advance(scorer.DocID() + 1) != DocIdSetIterator.NO_MORE_DOCS
+ : scorer.NextDoc() != DocIdSetIterator.NO_MORE_DOCS;
+ int scorerDoc = scorer.DocID();
float scorerScore = scorer.Score();
float scorerScore2 = scorer.Score();
float scoreDiff = System.Math.Abs(score - scorerScore);
float scorerDiff = System.Math.Abs(scorerScore2 - scorerScore);
- if (!more || doc != sdoc[0] || scoreDiff > maxDiff || scorerDiff > maxDiff)
+ if (!more || doc != scorerDoc || scoreDiff > maxDiff || scorerDiff > maxDiff)
{
System.Text.StringBuilder sbord = new System.Text.StringBuilder();
for (int i = 0; i < order.Length; i++)
sbord.Append(order[i] == skip_op?" skip()":" next()");
- throw new System.SystemException("ERROR matching docs:" + "\n\t" + (doc != sdoc[0]?"--> ":"") + "doc=" + sdoc[0] + "\n\t" + (!more?"--> ":"") + "tscorer.more=" + more + "\n\t" + (scoreDiff > maxDiff?"--> ":"") + "scorerScore=" + scorerScore + " scoreDiff=" + scoreDiff + " maxDiff=" + maxDiff + "\n\t" + (scorerDiff > maxDiff?"--> ":"") + "scorerScore2=" + scorerScore2 + " scorerDiff=" + scorerDiff + "\n\thitCollector.doc=" + doc + " score=" + score + "\n\t Scorer=" + scorer + "\n\t Query=" + q + " " + q.GetType().FullName + "\n\t Searcher=" + s + "\n\t Order=" + sbord + "\n\t Op=" + (op == skip_op?" skip()":" next()"));
+ throw new System.SystemException("ERROR matching docs:" + "\n\t" + (doc != scorerDoc ? "--> " : "") + "scorerDoc=" +
+ scorerDoc + "\n\t" + (!more ? "--> " : "") + "tscorer.more=" + more + "\n\t" +
+ (scoreDiff > maxDiff ? "--> " : "") + "scorerScore=" + scorerScore +
+ " scoreDiff=" + scoreDiff + " maxDiff=" + maxDiff + "\n\t" +
+ (scorerDiff > maxDiff ? "--> " : "") + "scorerScore2=" + scorerScore2 +
+ " scorerDiff=" + scorerDiff + "\n\thitCollector.doc=" + doc + " score=" +
+ score + "\n\t Scorer=" + scorer + "\n\t Query=" + q + " " +
+ q.GetType().FullName + "\n\t Searcher=" + s + "\n\t Order=" + sbord +
+ "\n\t Op=" + (op == skip_op ? " skip()" : " next()"));
}
}
catch (System.IO.IOException e)
@@ -108,7 +123,20 @@ namespace Lucene.Net.Search
public override void SetNextReader(IndexReader reader, int docBase)
{
- base_Renamed = docBase;
+ // confirm that skipping beyond the last doc, on the
+ // previous reader, hits NO_MORE_DOCS
+ if (lastReader[0] != null) {
+ IndexReader previousReader = lastReader[0];
+ Weight w = q.Weight(new IndexSearcher(previousReader));
+ Scorer scorer = w.Scorer(previousReader, true, false);
+ if (scorer != null) {
+ bool more = scorer.Advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
+ Assert.IsFalse(more, "query's last doc was "+ lastDoc[0] +" but skipTo("+(lastDoc[0]+1)+") got to "+scorer.DocID());
+ }
+ }
+ this.reader = reader;
+ this.scorer = null;
+ lastDoc[0] = -1;
}
public override bool AcceptsDocsOutOfOrder()
@@ -454,13 +482,21 @@ namespace Lucene.Net.Search
float maxDiff = 1e-5f;
IndexReader[] lastReader = new IndexReader[] {null};
- s.Search(q, new AnonymousClassCollector(order, opidx, skip_op, lastReader, lastDoc, maxDiff, q, s));
-
- // make sure next call to scorer is false.
- int op2 = order[(opidx[0]++) % order.Length];
- // System.out.println(op==skip_op ? "last: skip()":"last: next()");
- bool more = (op2 == skip_op ? scorer.Advance(sdoc[0] + 1) : scorer.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS;
- Assert.IsFalse(more);
+ s.Search(q, new AnonymousClassCollector(order, opidx, skip_op, lastReader, maxDiff, q, s, lastDoc));
+
+ if (lastReader[0] != null)
+ {
+ // Confirm that skipping beyond the last doc, on the
+ // previous reader, hits NO_MORE_DOCS
+ IndexReader previousReader = lastReader[0];
+ Weight w = q.Weight(new IndexSearcher(previousReader));
+ Scorer scorer = w.Scorer(previousReader, true, false);
+ if (scorer != null)
+ {
+ bool more = scorer.Advance(lastDoc[0] + 1) != DocIdSetIterator.NO_MORE_DOCS;
+ Assert.IsFalse(more, "query's last doc was " + lastDoc[0] + " but skipTo(" + (lastDoc[0] + 1) + ") got to " + scorer.DocID());
+ }
+ }
}
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBoolean2.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBoolean2.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBoolean2.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBoolean2.cs Tue Nov 15 08:41:44 2011
@@ -16,7 +16,8 @@
*/
using System;
-
+using Lucene.Net.Index;
+using Lucene.Net.Store;
using NUnit.Framework;
using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
@@ -64,8 +65,13 @@ namespace Lucene.Net.Search
}
}
private IndexSearcher searcher;
+ private IndexSearcher bigSearcher;
+ private IndexReader reader;
+ private static int NUM_EXTRA_DOCS = 6000;
public const System.String field = "field";
+ private Directory dir2;
+ private int mulFactor;
[SetUp]
public override void SetUp()
@@ -75,55 +81,84 @@ namespace Lucene.Net.Search
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
for (int i = 0; i < docFields.Length; i++)
{
- Document doc = new Document();
- doc.Add(new Field(field, docFields[i], Field.Store.NO, Field.Index.ANALYZED));
- writer.AddDocument(doc);
+ Document document = new Document();
+ document.Add(new Field(field, docFields[i], Field.Store.NO, Field.Index.ANALYZED));
+ writer.AddDocument(document);
}
writer.Close();
- searcher = new IndexSearcher(directory);
+ searcher = new IndexSearcher(directory, true);
+
+ // Make big index
+ dir2 = new MockRAMDirectory(directory);
+
+ // First multiply small test index:
+ mulFactor = 1;
+ int docCount = 0;
+ do
+ {
+ Directory copy = new RAMDirectory(dir2);
+ IndexWriter indexWriter = new IndexWriter(dir2, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ indexWriter.AddIndexesNoOptimize(new[] {copy});
+ docCount = indexWriter.MaxDoc();
+ indexWriter.Close();
+ mulFactor *= 2;
+ } while (docCount < 3000);
+
+ IndexWriter w = new IndexWriter(dir2, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ Document doc = new Document();
+ doc.Add(new Field("field2", "xxx", Field.Store.NO, Field.Index.ANALYZED));
+ for (int i = 0; i < NUM_EXTRA_DOCS / 2; i++)
+ {
+ w.AddDocument(doc);
+ }
+ doc = new Document();
+ doc.Add(new Field("field2", "big bad bug", Field.Store.NO, Field.Index.ANALYZED));
+ for (int i = 0; i < NUM_EXTRA_DOCS / 2; i++)
+ {
+ w.AddDocument(doc);
+ }
+ // optimize to 1 segment
+ w.Optimize();
+ reader = w.GetReader();
+ w.Close();
+ bigSearcher = new IndexSearcher(reader);
}
[TearDown]
public override void TearDown()
{
- searcher.Close();
- searcher = null;
- GC.Collect();
- base.TearDown();
+ reader.Close();
+ dir2.Close();
}
private System.String[] docFields = new System.String[]{"w1 w2 w3 w4 w5", "w1 w3 w2 w3", "w1 xx w2 yy w3", "w1 w3 xx w2 yy w3"};
public virtual Query MakeQuery(System.String queryText)
{
- Query q = (new QueryParser(field, new WhitespaceAnalyzer())).Parse(queryText);
+ Query q = (new QueryParser(Util.Version.LUCENE_CURRENT, field, new WhitespaceAnalyzer())).Parse(queryText);
return q;
}
-
- public virtual void QueriesTest(System.String queryText, int[] expDocNrs)
- {
- //System.out.println();
- //System.out.println("Query: " + queryText);
- try
- {
- Query query1 = MakeQuery(queryText);
- BooleanQuery.SetAllowDocsOutOfOrder(true);
- ScoreDoc[] hits1 = searcher.Search(query1, null, 1000).ScoreDocs;
-
- Query query2 = MakeQuery(queryText); // there should be no need to parse again...
- BooleanQuery.SetAllowDocsOutOfOrder(false);
- ScoreDoc[] hits2 = searcher.Search(query2, null, 1000).ScoreDocs;
-
- CheckHits.CheckHitsQuery(query2, hits1, hits2, expDocNrs);
- }
- finally
- {
- // even when a test fails.
- BooleanQuery.SetAllowDocsOutOfOrder(false);
- }
- }
-
- [Test]
+
+ public virtual void QueriesTest(System.String queryText, int[] expDocNrs)
+ {
+ //System.out.println();
+ //System.out.println("Query: " + queryText);
+ Query query1 = MakeQuery(queryText);
+ TopScoreDocCollector collector = TopScoreDocCollector.create(1000, false);
+ searcher.Search(query1, null, collector);
+ ScoreDoc[] hits1 = collector.TopDocs().ScoreDocs;
+
+ Query query2 = MakeQuery(queryText); // there should be no need to parse again...
+ collector = TopScoreDocCollector.create(1000, true);
+ searcher.Search(query2, null, collector);
+ ScoreDoc[] hits2 = collector.TopDocs().ScoreDocs;
+
+ Assert.AreEqual(mulFactor*collector.totalHits, bigSearcher.Search(query1, 1).TotalHits);
+
+ CheckHits.CheckHitsQuery(query2, hits1, hits2, expDocNrs);
+ }
+
+ [Test]
public virtual void TestQueries01()
{
System.String queryText = "+w3 +xx";
@@ -221,22 +256,29 @@ namespace Lucene.Net.Search
for (int i = 0; i < 1000; i++)
{
int level = rnd.Next(3);
- q1 = RandBoolQuery(new System.Random((System.Int32) rnd.Next(System.Int32.MaxValue)), level, field, vals, null);
+ q1 = RandBoolQuery(new System.Random(rnd.Next(System.Int32.MaxValue)), rnd.Next(0, 1) == 0 ? false : true, level, field, vals, null);
// Can't sort by relevance since floating point numbers may not quite
// match up.
Sort sort = Sort.INDEXORDER;
- BooleanQuery.SetAllowDocsOutOfOrder(false);
-
QueryUtils.Check(q1, searcher);
-
- ScoreDoc[] hits1 = searcher.Search(q1, null, 1000, sort).ScoreDocs;
-
- BooleanQuery.SetAllowDocsOutOfOrder(true);
- ScoreDoc[] hits2 = searcher.Search(q1, null, 1000, sort).ScoreDocs;
+
+ TopFieldCollector collector = TopFieldCollector.create(sort, 1000, false, true, true, true);
+ searcher.Search(q1, null, collector);
+ ScoreDoc[] hits1 = collector.TopDocs().ScoreDocs;
+
+ collector = TopFieldCollector.create(sort, 1000, false, true, true, false);
+ searcher.Search(q1, null, collector);
+ ScoreDoc[] hits2 = collector.TopDocs().ScoreDocs;
tot += hits2.Length;
CheckHits.CheckEqual(q1, hits1, hits2);
+
+ BooleanQuery q3 = new BooleanQuery();
+ q3.Add(q1, BooleanClause.Occur.SHOULD);
+ q3.Add(new PrefixQuery(new Term("Field", "b")), BooleanClause.Occur.SHOULD);
+ TopDocs hits4 = bigSearcher.Search(q3, 1);
+ Assert.AreEqual(mulFactor*collector.totalHits + NUM_EXTRA_DOCS/2, hits4.TotalHits);
}
}
catch (System.Exception e)
@@ -245,11 +287,6 @@ namespace Lucene.Net.Search
System.Console.Out.WriteLine("failed query: " + q1);
throw e;
}
- finally
- {
- // even when a test fails.
- BooleanQuery.SetAllowDocsOutOfOrder(false);
- }
// System.out.println("Total hits:"+tot);
}
@@ -264,7 +301,7 @@ namespace Lucene.Net.Search
// Random rnd is passed in so that the exact same random query may be created
// more than once.
- public static BooleanQuery RandBoolQuery(System.Random rnd, int level, System.String field, System.String[] vals, TestBoolean2.Callback cb)
+ public static BooleanQuery RandBoolQuery(System.Random rnd, bool allowMust, int level, System.String field, System.String[] vals, TestBoolean2.Callback cb)
{
BooleanQuery current = new BooleanQuery(rnd.Next() < 0);
for (int i = 0; i < rnd.Next(vals.Length) + 1; i++)
@@ -275,19 +312,33 @@ namespace Lucene.Net.Search
qType = rnd.Next(10);
}
Query q;
- if (qType < 7)
- q = new TermQuery(new Term(field, vals[rnd.Next(vals.Length)]));
- else
- q = RandBoolQuery(rnd, level - 1, field, vals, cb);
-
- int r = rnd.Next(10);
+ if (qType < 3)
+ {
+ q = new TermQuery(new Term(field, vals[rnd.Next(vals.Length)]));
+ }
+ else if (qType < 7)
+ {
+ q = new WildcardQuery(new Term(field, "w*"));
+ }
+ else
+ {
+ q = RandBoolQuery(rnd, allowMust, level - 1, field, vals, cb);
+ }
+
+ int r = rnd.Next(10);
BooleanClause.Occur occur;
- if (r < 2)
- occur = BooleanClause.Occur.MUST_NOT;
- else if (r < 5)
- occur = BooleanClause.Occur.MUST;
- else
- occur = BooleanClause.Occur.SHOULD;
+ if (r < 2)
+ {
+ occur = BooleanClause.Occur.MUST_NOT;
+ }
+ else if (r < 5)
+ {
+ occur = allowMust ? BooleanClause.Occur.MUST : BooleanClause.Occur.SHOULD;
+ }
+ else
+ {
+ occur = BooleanClause.Occur.SHOULD;
+ }
current.Add(q, occur);
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanMinShouldMatch.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanMinShouldMatch.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanMinShouldMatch.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanMinShouldMatch.cs Tue Nov 15 08:41:44 2011
@@ -101,7 +101,7 @@ namespace Lucene.Net.Search
writer.Optimize();
writer.Close();
- r = IndexReader.Open(index);
+ r = IndexReader.Open(index, true);
s = new IndexSearcher(r);
//System.out.println("Set up " + getName());
@@ -370,9 +370,9 @@ namespace Lucene.Net.Search
{
int lev = rnd.Next(maxLev);
long seed = rnd.Next(System.Int32.MaxValue);
- BooleanQuery q1 = TestBoolean2.RandBoolQuery(new System.Random((System.Int32) seed), lev, field, vals, null);
+ BooleanQuery q1 = TestBoolean2.RandBoolQuery(new System.Random((System.Int32) seed), true, lev, field, vals, null);
// BooleanQuery q2 = TestBoolean2.randBoolQuery(new Random(seed), lev, field, vals, minNrCB);
- BooleanQuery q2 = TestBoolean2.RandBoolQuery(new System.Random((System.Int32) seed), lev, field, vals, null);
+ BooleanQuery q2 = TestBoolean2.RandBoolQuery(new System.Random((System.Int32) seed), true, lev, field, vals, null);
// only set minimumNumberShouldMatch on the top level query since setting
// at a lower level can change the score.
minNrCB.PostCreate(q2);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanOr.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanOr.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanOr.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanOr.cs Tue Nov 15 08:41:44 2011
@@ -139,13 +139,12 @@ namespace Lucene.Net.Search
public override void SetUp()
{
base.SetUp();
- base.SetUp();
//
RAMDirectory rd = new RAMDirectory();
//
- IndexWriter writer = new IndexWriter(rd, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(rd, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
//
Document d = new Document();
@@ -157,7 +156,7 @@ namespace Lucene.Net.Search
writer.Close();
//
- searcher = new IndexSearcher(rd);
+ searcher = new IndexSearcher(rd, true);
}
}
}
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanPrefixQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanPrefixQuery.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanPrefixQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanPrefixQuery.cs Tue Nov 15 08:41:44 2011
@@ -32,10 +32,6 @@ namespace Lucene.Net.Search
{
/// <summary> </summary>
- /// <version> $Id: TestBooleanPrefixQuery.java 808519 2009-08-27 16:57:27Z mikemccand $
- ///
- /// </version>
-
[TestFixture]
public class TestBooleanPrefixQuery:LuceneTestCase
{
@@ -97,8 +93,8 @@ namespace Lucene.Net.Search
writer.AddDocument(doc);
}
writer.Close();
-
- reader = IndexReader.Open(directory);
+
+ reader = IndexReader.Open(directory, true);
PrefixQuery query = new PrefixQuery(new Term("category", "foo"));
rw1 = query.Rewrite(reader);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanQuery.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanQuery.cs Tue Nov 15 08:41:44 2011
@@ -81,11 +81,37 @@ namespace Lucene.Net.Search
Document doc = new Document();
doc.Add(new Field("field", "a b c d", Field.Store.NO, Field.Index.ANALYZED));
w.AddDocument(doc);
+
IndexReader r = w.GetReader();
IndexSearcher s = new IndexSearcher(r);
BooleanQuery q = new BooleanQuery();
q.Add(new TermQuery(new Term("field", "a")), BooleanClause.Occur.SHOULD);
-
+
+ // LUCENE-2617: make sure that a term not in the index still contributes to the score via coord factor
+ float score = s.Search(q, 10).GetMaxScore();
+ Query subQuery = new TermQuery(new Term("field", "not_in_index"));
+ subQuery.SetBoost(0);
+ q.Add(subQuery, BooleanClause.Occur.SHOULD);
+ float score2 = s.Search(q, 10).GetMaxScore();
+ Assert.AreEqual(score * .5, score2, 1e-6);
+
+ // LUCENE-2617: make sure that a clause not in the index still contributes to the score via coord factor
+ BooleanQuery qq = (BooleanQuery)q.Clone();
+ PhraseQuery phrase = new PhraseQuery();
+ phrase.Add(new Term("field", "not_in_index"));
+ phrase.Add(new Term("field", "another_not_in_index"));
+ phrase.SetBoost(0);
+ qq.Add(phrase, BooleanClause.Occur.SHOULD);
+ score2 = s.Search(qq, 10).GetMaxScore();
+ Assert.AreEqual(score * (1.0 / 3), score2, 1e-6);
+
+ // now test BooleanScorer2
+ subQuery = new TermQuery(new Term("field", "b"));
+ subQuery.SetBoost(0);
+ q.Add(subQuery, BooleanClause.Occur.MUST);
+ score2 = s.Search(q, 10).GetMaxScore();
+ Assert.AreEqual(score * (2.0 / 3), score2, 1e-6);
+
// PhraseQuery w/ no terms added returns a null scorer
PhraseQuery pq = new PhraseQuery();
q.Add(pq, BooleanClause.Occur.SHOULD);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanScorer.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestBooleanScorer.cs Tue Nov 15 08:41:44 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using System.Collections.Generic;
using NUnit.Framework;
using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
@@ -29,10 +29,6 @@ using LuceneTestCase = Lucene.Net.Util.L
namespace Lucene.Net.Search
{
-
- /// <summary> </summary>
- /// <version> $rcs = ' $Id: TestBooleanScorer.java 782410 2009-06-07 16:58:41Z mikemccand $ ' ;
- /// </version>
[TestFixture]
public class TestBooleanScorer:LuceneTestCase
{
@@ -64,41 +60,19 @@ namespace Lucene.Net.Search
{
return 0;
}
- /// <deprecated> delete in 3.0.
- /// </deprecated>
- [Obsolete("delete in 3.0")]
- public override int Doc()
- {
- return 3000;
- }
public override int DocID()
{
return doc;
}
- /// <deprecated> delete in 3.0
- /// </deprecated>
- [Obsolete("delete in 3.0")]
- public override bool Next()
- {
- return NextDoc() != NO_MORE_DOCS;
- }
public override int NextDoc()
{
- return doc = doc == - 1?3000:NO_MORE_DOCS;
+ return doc = doc == -1 ? 3000 : NO_MORE_DOCS;
}
-
- /// <deprecated> delete in 3.0
- /// </deprecated>
- [Obsolete("delete in 3.0")]
- public override bool SkipTo(int target)
- {
- return Advance(target) != NO_MORE_DOCS;
- }
-
+
public override int Advance(int target)
{
- return doc = target <= 3000?3000:NO_MORE_DOCS;
+ return doc = target <= 3000 ? 3000 : NO_MORE_DOCS;
}
}
@@ -134,7 +108,7 @@ namespace Lucene.Net.Search
query.Add(booleanQuery1, BooleanClause.Occur.MUST);
query.Add(new TermQuery(new Term(FIELD, "9")), BooleanClause.Occur.MUST_NOT);
- IndexSearcher indexSearcher = new IndexSearcher(directory);
+ IndexSearcher indexSearcher = new IndexSearcher(directory, true);
ScoreDoc[] hits = indexSearcher.Search(query, null, 1000).ScoreDocs;
Assert.AreEqual(2, hits.Length, "Number of matched documents");
}
@@ -154,7 +128,7 @@ namespace Lucene.Net.Search
Similarity sim = Similarity.GetDefault();
Scorer[] scorers = new Scorer[]{new AnonymousClassScorer(this, sim)};
- BooleanScorer bs = new BooleanScorer(sim, 1, new System.Collections.ArrayList(scorers), null);
+ BooleanScorer bs = new BooleanScorer(sim, 1, new List<Scorer>(scorers), null);
Assert.AreEqual(3000, bs.NextDoc(), "should have received 3000");
Assert.AreEqual(DocIdSetIterator.NO_MORE_DOCS, bs.NextDoc(), "should have received NO_MORE_DOCS");
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestCachingWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestCachingWrapperFilter.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestCachingWrapperFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestCachingWrapperFilter.cs Tue Nov 15 08:41:44 2011
@@ -41,7 +41,7 @@ namespace Lucene.Net.Search
IndexWriter writer = new IndexWriter(dir, new KeywordAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
writer.Close();
- IndexReader reader = IndexReader.Open(dir);
+ IndexReader reader = IndexReader.Open(dir, true);
MockFilter filter = new MockFilter();
CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
@@ -50,8 +50,7 @@ namespace Lucene.Net.Search
cacher.GetDocIdSet(reader);
Assert.IsTrue(filter.WasCalled(), "first time");
- // make sure no exception if cache is holding the wrong bitset
- cacher.Bits(reader);
+ // make sure no exception if cache is holding the wrong DocIdSet
cacher.GetDocIdSet(reader);
// second time, nested filter should not be called
@@ -100,17 +99,6 @@ namespace Lucene.Net.Search
IndexReader reader = IndexReader.Open(dir, true);
Filter filter = new AnonymousFilter2();
- //final Filter filter = new Filter() {
- // //@Override
- // public DocIdSet getDocIdSet(IndexReader reader) {
- // return new DocIdSet() {
- // //@Override
- // public DocIdSetIterator iterator() {
- // return null;
- // }
- // };
- // }
- //};
CachingWrapperFilter cacher = new CachingWrapperFilter(filter);
// the caching filter should return the empty set constant
@@ -154,13 +142,13 @@ namespace Lucene.Net.Search
}
[Test]
- public void TestIsCacheAble()
+ public void TestIsCacheable()
{
Directory dir = new RAMDirectory();
IndexWriter writer = new IndexWriter(dir, new KeywordAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
writer.Close();
- IndexReader reader = IndexReader.Open(dir);
+ IndexReader reader = IndexReader.Open(dir, true);
// not cacheable:
assertDocIdSetCacheable(reader, new QueryWrapperFilter(new TermQuery(new Term("test", "value"))), false);
@@ -170,24 +158,10 @@ namespace Lucene.Net.Search
assertDocIdSetCacheable(reader, FieldCacheRangeFilter.NewIntRange("test", 10, 20, true, true), true);
// a openbitset filter is always cacheable
assertDocIdSetCacheable(reader, new AnonymousFilter3(), true);
- // a deprecated filter is always cacheable
- assertDocIdSetCacheable(reader, new AnonymousFilter4(), true);
reader.Close();
}
- /*
- new Filter() {
- public DocIdSet getDocIdSet(IndexReader reader) {
- return new OpenBitSet();
- }
- }
-
- * new Filter() {
- public BitSet bits(IndexReader reader) {
- return new BitSet();
- }
- }
- */
+
class AnonymousFilter3 : Filter
{
public override DocIdSet GetDocIdSet(IndexReader reader)
@@ -196,14 +170,6 @@ namespace Lucene.Net.Search
}
}
- class AnonymousFilter4 : Filter
- {
- public override System.Collections.BitArray Bits(IndexReader reader)
- {
- return new System.Collections.BitArray(100000); //DIGY
- }
- }
-
[Test]
public void TestEnforceDeletions()
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestCustomSearcherSort.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestCustomSearcherSort.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestCustomSearcherSort.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestCustomSearcherSort.cs Tue Nov 15 08:41:44 2011
@@ -67,7 +67,7 @@ namespace Lucene.Net.Search
private Directory GetIndex()
{
RAMDirectory indexStore = new RAMDirectory();
- IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
RandomGen random = new RandomGen(this, NewRandom());
for (int i = 0; i < INDEX_SIZE; ++i)
{
@@ -107,7 +107,7 @@ namespace Lucene.Net.Search
{
// log("Run testFieldSortCustomSearcher");
// define the sort criteria
- Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
+ Sort custSort = new Sort(new SortField("publicationDate_", SortField.STRING), SortField.FIELD_SCORE);
Searcher searcher = new CustomSearcher(this, index, 2);
// search and check hits
MatchHits(searcher, custSort);
@@ -118,7 +118,7 @@ namespace Lucene.Net.Search
{
// log("Run testFieldSortSingleSearcher");
// define the sort criteria
- Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
+ Sort custSort = new Sort(new SortField("publicationDate_"), SortField.FIELD_SCORE);
Searcher searcher = new MultiSearcher(new Searcher[]{new CustomSearcher(this, index, 2)});
// search and check hits
MatchHits(searcher, custSort);
@@ -129,7 +129,7 @@ namespace Lucene.Net.Search
{
// log("Run testFieldSortMultiCustomSearcher");
// define the sort criteria
- Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
+ Sort custSort = new Sort(new SortField("publicationDate_"), SortField.FIELD_SCORE);
Searcher searcher = new MultiSearcher(new Searchable[]{new CustomSearcher(this, index, 0), new CustomSearcher(this, index, 2)});
// search and check hits
MatchHits(searcher, custSort);
@@ -146,7 +146,7 @@ namespace Lucene.Net.Search
// store hits in TreeMap - TreeMap does not allow duplicates; existing entries are silently overwritten
for (int hitid = 0; hitid < hitsByRank.Length; ++hitid)
{
- resultMap[(System.Int32) hitsByRank[hitid].doc] = (System.Int32) hitid; // Value: Hits-Objekt Index
+ resultMap[hitsByRank[hitid].doc] = hitid; // Value: Hits-Objekt Index
}
// now make a query using the sort criteria
@@ -187,9 +187,9 @@ namespace Lucene.Net.Search
System.Collections.IDictionary idMap = new System.Collections.SortedList();
for (int docnum = 0; docnum < hits.Length; ++docnum)
{
- System.Int32 luceneId;
+ int luceneId;
- luceneId = (System.Int32) hits[docnum].doc;
+ luceneId = hits[docnum].doc;
if (idMap.Contains(luceneId))
{
System.Text.StringBuilder message = new System.Text.StringBuilder(prefix);
@@ -203,7 +203,7 @@ namespace Lucene.Net.Search
}
else
{
- idMap[luceneId] = (System.Int32) docnum;
+ idMap[luceneId] = docnum;
}
}
}
@@ -246,14 +246,6 @@ namespace Lucene.Net.Search
InitBlock(enclosingInstance);
this.switcher = switcher;
}
- /// <param name="path">
- /// </param>
- /// <throws> IOException </throws>
- public CustomSearcher(TestCustomSearcherSort enclosingInstance, System.String path, int switcher):base(path)
- {
- InitBlock(enclosingInstance);
- this.switcher = switcher;
- }
/* (non-Javadoc)
* @see Lucene.Net.Search.Searchable#search(Lucene.Net.Search.Query, Lucene.Net.Search.Filter, int, Lucene.Net.Search.Sort)
*/
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestDateSort.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestDateSort.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestDateSort.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestDateSort.cs Tue Nov 15 08:41:44 2011
@@ -72,13 +72,11 @@ namespace Lucene.Net.Search
[Test]
public virtual void TestReverseDateSort()
{
- IndexSearcher searcher = new IndexSearcher(directory);
+ IndexSearcher searcher = new IndexSearcher(directory, true);
- // Create a Sort object. reverse is set to true.
- // problem occurs only with SortField.AUTO:
- Sort sort = new Sort(new SortField(DATE_TIME_FIELD, SortField.AUTO, true));
+ Sort sort = new Sort(new SortField(DATE_TIME_FIELD, SortField.STRING, true));
- QueryParser queryParser = new QueryParser(TEXT_FIELD, new WhitespaceAnalyzer());
+ QueryParser queryParser = new QueryParser(Util.Version.LUCENE_CURRENT, TEXT_FIELD, new WhitespaceAnalyzer());
Query query = queryParser.Parse("Document");
// Execute the search and process the search results.
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestDocIdSet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestDocIdSet.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestDocIdSet.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestDocIdSet.cs Tue Nov 15 08:41:44 2011
@@ -68,25 +68,11 @@ namespace Lucene.Net.Search
internal int docid = - 1;
- /** @deprecated use {@link #DocID()} instead. */
- public override int Doc()
- {
- return docid;
- }
-
public override int DocID()
{
return docid;
}
- /// <deprecated> use {@link #NextDoc()} instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead. ")]
- public override bool Next()
- {
- return NextDoc() != NO_MORE_DOCS;
- }
-
//@Override
public override int NextDoc()
{
@@ -94,14 +80,6 @@ namespace Lucene.Net.Search
return docid < maxdoc?docid:(docid = NO_MORE_DOCS);
}
- /// <deprecated> use {@link #Advance(int)} instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead. ")]
- public override bool SkipTo(int target)
- {
- return Advance(target) != NO_MORE_DOCS;
- }
-
//@Override
public override int Advance(int target)
{
@@ -127,7 +105,6 @@ namespace Lucene.Net.Search
}
- // @Override
public override DocIdSetIterator Iterator()
{
return new AnonymousClassDocIdSetIterator(maxdoc, this);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestElevationComparator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestElevationComparator.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestElevationComparator.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestElevationComparator.cs Tue Nov 15 08:41:44 2011
@@ -74,7 +74,7 @@ namespace Lucene.Net.Search
Sort sort = new Sort(new SortField[]{new SortField("id", new ElevationComparatorSource(priority), false), new SortField(null, SortField.SCORE, reversed)});
- TopDocsCollector topCollector = TopFieldCollector.create(sort, 50, false, true, true, true);
+ TopFieldCollector topCollector = TopFieldCollector.create(sort, 50, false, true, true, true);
searcher.Search(newq, null, topCollector);
TopDocs topDocs = topCollector.TopDocs(0, 10);
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestExplanations.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestExplanations.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestExplanations.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestExplanations.cs Tue Nov 15 08:41:44 2011
@@ -56,7 +56,7 @@ namespace Lucene.Net.Search
public const System.String KEY = "KEY";
public const System.String FIELD = "field";
- public static readonly QueryParser qp = new QueryParser(FIELD, new WhitespaceAnalyzer());
+ public static readonly QueryParser qp = new QueryParser(Util.Version.LUCENE_CURRENT, FIELD, new WhitespaceAnalyzer());
[TearDown]
public override void TearDown()
@@ -81,7 +81,7 @@ namespace Lucene.Net.Search
writer.AddDocument(doc);
}
writer.Close();
- searcher = new IndexSearcher(directory);
+ searcher = new IndexSearcher(directory, true);
}
protected internal System.String[] docFields = new System.String[]{"w1 w2 w3 w4 w5", "w1 w3 w2 w3 zz", "w1 xx w2 yy w3", "w1 w3 xx w2 yy w3 zz"};
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFilteredQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFilteredQuery.cs?rev=1202091&r1=1202090&r2=1202091&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFilteredQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Search/TestFilteredQuery.cs Tue Nov 15 08:41:44 2011
@@ -34,15 +34,8 @@ namespace Lucene.Net.Search
{
/// <summary> FilteredQuery JUnit tests.
- ///
/// <p/>Created: Apr 21, 2004 1:21:46 PM
- ///
- ///
/// </summary>
- /// <version> $Id: TestFilteredQuery.java 807821 2009-08-25 21:55:49Z mikemccand $
- /// </version>
- /// <since> 1.4
- /// </since>
[TestFixture]
public class TestFilteredQuery:LuceneTestCase
{
@@ -103,7 +96,7 @@ namespace Lucene.Net.Search
writer.Optimize();
writer.Close();
- searcher = new IndexSearcher(directory);
+ searcher = new IndexSearcher(directory, true);
query = new TermQuery(new Term("field", "three"));
filter = NewStaticFilterB();
}
@@ -131,7 +124,7 @@ namespace Lucene.Net.Search
Assert.AreEqual(1, hits[0].doc);
QueryUtils.Check(filteredquery, searcher);
- hits = searcher.Search(filteredquery, null, 1000, new Sort("sorter")).ScoreDocs;
+ hits = searcher.Search(filteredquery, null, 1000, new Sort(new SortField("sorter", SortField.STRING))).ScoreDocs;
Assert.AreEqual(1, hits.Length);
Assert.AreEqual(1, hits[0].doc);