You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ar...@apache.org on 2009/11/17 02:13:58 UTC
svn commit: r881077 [2/2] - in /incubator/lucene.net/trunk/C#/src: ./
Demo/DeleteFiles/ Demo/DemoLib/ Demo/IndexFiles/ Demo/IndexHtml/
Demo/SearchFiles/ Lucene.Net/ Lucene.Net/Analysis/
Lucene.Net/Analysis/Standard/ Lucene.Net/Index/ Lucene.Net/QueryPa...
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/IndexSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/IndexSearcher.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/IndexSearcher.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/IndexSearcher.cs Tue Nov 17 01:13:56 2009
@@ -194,13 +194,15 @@
}
/// <summary> Just like {@link #Search(Weight, Filter, int, Sort)}, but you choose
- /// whether or not the fields in the returned {@link FieldDoc} instances should
- /// be set by specifying fillFields.<br>
- /// <b>NOTE:</b> currently, this method tracks document scores and sets them in
- /// the returned {@link FieldDoc}, however in 3.0 it will move to not track
- /// document scores. If document scores tracking is still needed, you can use
- /// {@link #Search(Weight, Filter, Collector)} and pass in a
- /// {@link TopFieldCollector} instance.
+ /// whether or not the fields in the returned {@link FieldDoc} instances
+ /// should be set by specifying fillFields.<br>
+ ///
+ /// <p>
+ /// NOTE: this does not compute scores by default. If you need scores, create
+ /// a {@link TopFieldCollector} instance by calling
+ /// {@link TopFieldCollector#create} and then pass that to
+ /// {@link #Search(Weight, Filter, Collector)}.
+ /// </p>
/// </summary>
public virtual TopFieldDocs Search(Weight weight, Filter filter, int nDocs, Sort sort, bool fillFields)
{
@@ -362,8 +364,18 @@
private bool fieldSortDoTrackScores;
private bool fieldSortDoMaxScore;
- /// <deprecated>
- /// </deprecated>
+ /// <summary> By default, no scores are computed when sorting by field (using
+ /// {@link #Search(Query,Filter,int,Sort)}). You can change that, per
+ /// IndexSearcher instance, by calling this method. Note that this will incur
+ /// a CPU cost.
+ ///
+ /// </summary>
+ /// <param name="doTrackScores">If true, then scores are returned for every matching document
+ /// in {@link TopFieldDocs}.
+ ///
+ /// </param>
+ /// <param name="doMaxScore">If true, then the max score for all matching docs is computed.
+ /// </param>
public virtual void SetDefaultFieldSortScoring(bool doTrackScores, bool doMaxScore)
{
fieldSortDoTrackScores = doTrackScores;
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/NumericRangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/NumericRangeQuery.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/NumericRangeQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/NumericRangeQuery.cs Tue Nov 17 01:13:56 2009
@@ -188,6 +188,12 @@
throw new System.ArgumentException("valSize must be 32 or 64");
}
+
+ // shortcut if upper bound == lower bound
+ if (min != null && min.Equals(max))
+ {
+ SetRewriteMethod(CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE);
+ }
}
/// <summary> Factory that creates a <code>NumericRangeQuery</code>, that queries a <code>long</code>
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Payloads/PayloadNearQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Payloads/PayloadNearQuery.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Payloads/PayloadNearQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Payloads/PayloadNearQuery.cs Tue Nov 17 01:13:56 2009
@@ -255,6 +255,10 @@
//
public /*protected internal*/ override bool SetFreqCurrentDoc()
{
+ if (!more)
+ {
+ return false;
+ }
Lucene.Net.Search.Spans.Spans[] spansArr = new Lucene.Net.Search.Spans.Spans[1];
spansArr[0] = spans;
payloadScore = 0;
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Scorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Scorer.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Scorer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Scorer.cs Tue Nov 17 01:13:56 2009
@@ -126,7 +126,7 @@
collector.Collect(doc);
doc = NextDoc();
}
- return doc == NO_MORE_DOCS;
+ return doc != NO_MORE_DOCS;
}
/// <summary>Returns the score of the current document matching the query.
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searchable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Searchable.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searchable.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searchable.cs Tue Nov 17 01:13:56 2009
@@ -123,8 +123,6 @@
/// {@link Searcher#Search(Query,Filter)} instead.
/// </summary>
/// <throws> BooleanQuery.TooManyClauses </throws>
- /// <deprecated> use {@link #Search(Weight, Filter, int)} instead.
- /// </deprecated>
TopDocs Search(Weight weight, Filter filter, int n);
/// <summary>Expert: Returns the stored fields of document <code>i</code>.
@@ -189,8 +187,8 @@
/// <code>filter</code> if non-null, and sorting the hits by the criteria in
/// <code>sort</code>.
///
- /// <p>Applications should usually call {@link
- /// Searcher#Search(Query,Filter,Sort)} instead.
+ /// <p>Applications should usually call
+ /// {@link Searcher#Search(Query,Filter,int,Sort)} instead.
///
/// </summary>
/// <throws> BooleanQuery.TooManyClauses </throws>
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Searcher.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searcher.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searcher.cs Tue Nov 17 01:13:56 2009
@@ -93,11 +93,8 @@
/// <code>filter</code> if non-null, and sorting the hits by the criteria in
/// <code>sort</code>.
///
- /// <b>NOTE:</b> currently, this method tracks document scores and sets them in
- /// the returned {@link FieldDoc}, however in 3.0 it will move to not track
- /// document scores. If document scores tracking is still needed, you can use
- /// {@link #Search(Weight, Filter, Collector)} and pass in a
- /// {@link TopFieldCollector} instance.
+ /// <p>NOTE: this does not compute scores by default; use
+ /// {@link IndexSearcher#setDefaultFieldSortScoring} to enable scoring.
///
/// </summary>
/// <throws> BooleanQuery.TooManyClauses </throws>
@@ -131,10 +128,9 @@
///
/// <p>{@link Collector#Collect(int)} is called for every matching document.
///
- /// <p>Applications should only use this if they need <i>all</i> of the
- /// matching documents. The high-level search API ({@link
- /// Searcher#Search(Query)}) is usually more efficient, as it skips
- /// non-high-scoring hits.
+ /// <p>Applications should only use this if they need <i>all</i> of the matching
+ /// documents. The high-level search API ({@link Searcher#Search(Query, int)}
+ /// ) is usually more efficient, as it skips non-high-scoring hits.
/// <p>Note: The <code>score</code> passed to this method is a raw score.
/// In other words, the score will not necessarily be a float whose value is
/// between 0 and 1.
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/Constants.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs Tue Nov 17 01:13:56 2009
@@ -26,7 +26,7 @@
///
///
/// </summary>
- /// <version> $Id: Constants.java 780225 2009-05-30 10:00:45Z mikemccand $
+ /// <version> $Id: Constants.java 828327 2009-10-22 06:47:40Z uschindler $
///
/// </version>
@@ -61,8 +61,16 @@
// NOTE: this logic may not be correct; if you know of a
// more reliable approach please raise it on java-dev!
public static bool JRE_IS_64BIT;
-
- public const System.String LUCENE_MAIN_VERSION = "2.9";
+
+ // this method prevents inlining the final version constant in compiled
+ // classes,
+ // see: http://www.javaworld.com/community/node/3400
+ private static System.String Ident(System.String s)
+ {
+ return s.ToString();
+ }
+
+ public static readonly System.String LUCENE_MAIN_VERSION = Ident("2.9.1");
public static System.String LUCENE_VERSION;
static Constants()
@@ -98,7 +106,7 @@
{
v = v + " [" + LUCENE_MAIN_VERSION + "]";
}
- LUCENE_VERSION = v;
+ LUCENE_VERSION = Ident(v);
*/
LUCENE_VERSION = " [" + LUCENE_MAIN_VERSION + "]";
// {{Aroush-2.9}}
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Version.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Util/Version.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Version.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Util/Version.cs Tue Nov 17 01:13:56 2009
@@ -38,6 +38,18 @@
/// </summary>
public static readonly Version LUCENE_CURRENT = new Version("LUCENE_CURRENT", 0);
+ /// <summary>Match settings and bugs in Lucene's 2.0 release. </summary>
+ public static readonly Version LUCENE_20 = new Version("LUCENE_20", 2000);
+
+ /// <summary>Match settings and bugs in Lucene's 2.1 release. </summary>
+ public static readonly Version LUCENE_21 = new Version("LUCENE_21", 2100);
+
+ /// <summary>Match settings and bugs in Lucene's 2.2 release. </summary>
+ public static readonly Version LUCENE_22 = new Version("LUCENE_22", 2200);
+
+ /// <summary>Match settings and bugs in Lucene's 2.3 release. </summary>
+ public static readonly Version LUCENE_23 = new Version("LUCENE_23", 2300);
+
/// <summary>Match settings and bugs in Lucene's 2.4 release.</summary>
/// <deprecated> This will be removed in 3.0
/// </deprecated>
Modified: incubator/lucene.net/trunk/C#/src/Test/Analysis/BaseTokenStreamTestCase.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/BaseTokenStreamTestCase.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/BaseTokenStreamTestCase.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/BaseTokenStreamTestCase.cs Tue Nov 17 01:13:56 2009
@@ -128,6 +128,17 @@
ts.Reset();
for (int i = 0; i < output.Length; i++)
{
+ // extra safety to enforce, that the state is not preserved and also
+ // assign bogus values
+ ts.ClearAttributes();
+ termAtt.SetTermBuffer("bogusTerm");
+ if (offsetAtt != null)
+ offsetAtt.SetOffset(14584724, 24683243);
+ if (typeAtt != null)
+ typeAtt.SetType("bogusType");
+ if (posIncrAtt != null)
+ posIncrAtt.SetPositionIncrement(45987657);
+
Assert.IsTrue(ts.IncrementToken(), "token " + i + " exists");
Assert.AreEqual(output[i], termAtt.Term(), "term " + i);
if (startOffsets != null)
@@ -140,6 +151,7 @@
Assert.AreEqual(posIncrements[i], posIncrAtt.GetPositionIncrement(), "posIncrement " + i);
}
Assert.IsFalse(ts.IncrementToken(), "end of stream");
+ ts.End();
ts.Close();
}
Modified: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStandardAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestStandardAnalyzer.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStandardAnalyzer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestStandardAnalyzer.cs Tue Nov 17 01:13:56 2009
@@ -24,6 +24,7 @@
using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
using TypeAttribute = Lucene.Net.Analysis.Tokenattributes.TypeAttribute;
+using Version = Lucene.Net.Util.Version;
namespace Lucene.Net.Analysis
{
@@ -138,15 +139,24 @@
[Test]
public virtual void TestDomainNames()
{
- // Don't reuse a because we alter its state (setReplaceInvalidAcronym)
- StandardAnalyzer a2 = new StandardAnalyzer();
+ // Don't reuse a because we alter its state
+ // (setReplaceInvalidAcronym)
+
+ // Current lucene should not show the bug
+ StandardAnalyzer a2 = new StandardAnalyzer(Version.LUCENE_CURRENT);
// domain names
AssertAnalyzesTo(a2, "www.nutch.org", new System.String[]{"www.nutch.org"});
//Notice the trailing . See https://issues.apache.org/jira/browse/LUCENE-1068.
// the following should be recognized as HOST:
AssertAnalyzesTo(a2, "www.nutch.org.", new System.String[]{"www.nutch.org"}, new System.String[]{"<HOST>"});
- a2.SetReplaceInvalidAcronym(false);
+
+ // 2.3 should show the bug
+ a2 = new StandardAnalyzer(Version.LUCENE_23);
AssertAnalyzesTo(a2, "www.nutch.org.", new System.String[]{"wwwnutchorg"}, new System.String[]{"<ACRONYM>"});
+
+ // 2.4 should not show the bug
+ a2 = new StandardAnalyzer(Version.LUCENE_24);
+ AssertAnalyzesTo(a2, "www.nutch.org.", new System.String[]{"www.nutch.org"}, new System.String[]{"<HOST>"});
}
[Test]
Modified: incubator/lucene.net/trunk/C#/src/Test/Analysis/TestTokenStreamBWComp.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Analysis/TestTokenStreamBWComp.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Analysis/TestTokenStreamBWComp.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Analysis/TestTokenStreamBWComp.cs Tue Nov 17 01:13:56 2009
@@ -21,6 +21,8 @@
using Lucene.Net.Analysis.Tokenattributes;
using Payload = Lucene.Net.Index.Payload;
+using Attribute = Lucene.Net.Util.Attribute;
+using AttributeImpl = Lucene.Net.Util.AttributeImpl;
using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Analysis
@@ -54,6 +56,7 @@
private System.String doc = "This is the new TokenStream api";
private System.String[] stopwords = new System.String[]{"is", "the", "this"};
+ private static System.String[] results = new System.String[]{"new", "tokenstream", "api"};
[Serializable]
public class POSToken:Token
@@ -257,6 +260,7 @@
PayloadAttribute payloadAtt = (PayloadAttribute) stream.AddAttribute(typeof(PayloadAttribute));
TermAttribute termAtt = (TermAttribute) stream.AddAttribute(typeof(TermAttribute));
+ int i = 0;
while (stream.IncrementToken())
{
System.String term = termAtt.Term();
@@ -269,6 +273,8 @@
{
Assert.IsFalse("tokenstream".Equals(term), "all other tokens (if this test fails, the special POSToken subclass is not correctly passed through the chain)");
}
+ Assert.AreEqual(results[i], term);
+ i++;
}
}
@@ -277,6 +283,7 @@
stream.Reset();
Token reusableToken = new Token();
+ int i = 0;
while ((reusableToken = stream.Next(reusableToken)) != null)
{
System.String term = reusableToken.Term();
@@ -289,6 +296,8 @@
{
Assert.IsFalse("tokenstream".Equals(term), "all other tokens (if this test fails, the special POSToken subclass is not correctly passed through the chain)");
}
+ Assert.AreEqual(results[i], term);
+ i++;
}
}
@@ -297,6 +306,7 @@
stream.Reset();
Token token;
+ int i = 0;
while ((token = stream.Next()) != null)
{
System.String term = token.Term();
@@ -309,6 +319,33 @@
{
Assert.IsFalse("tokenstream".Equals(term), "all other tokens (if this test fails, the special POSToken subclass is not correctly passed through the chain)");
}
+ Assert.AreEqual(results[i], term);
+ i++;
+ }
+ }
+
+ public interface SenselessAttribute:Attribute
+ {
+ }
+
+ public sealed class SenselessAttributeImpl:AttributeImpl, TestTokenStreamBWComp.SenselessAttribute
+ {
+ public override void CopyTo(AttributeImpl target)
+ {
+ }
+
+ public override void Clear()
+ {
+ }
+
+ public override bool Equals(System.Object o)
+ {
+ return (o is SenselessAttributeImpl);
+ }
+
+ public override int GetHashCode()
+ {
+ return 0;
}
}
@@ -350,6 +387,7 @@
Assert.IsTrue(stream2.AddAttribute(typeof(PayloadAttribute)) is PayloadAttributeImpl, "PayloadAttribute is implemented by PayloadAttributeImpl");
Assert.IsTrue(stream2.AddAttribute(typeof(PositionIncrementAttribute)) is PositionIncrementAttributeImpl, "PositionIncrementAttribute is implemented by PositionIncrementAttributeImpl");
Assert.IsTrue(stream2.AddAttribute(typeof(TypeAttribute)) is TypeAttributeImpl, "TypeAttribute is implemented by TypeAttributeImpl");
+ Assert.IsTrue(stream2.AddAttribute(typeof(TestTokenStreamBWComp.SenselessAttribute)) is SenselessAttributeImpl, "SenselessAttribute is not implemented by SenselessAttributeImpl");
// try to call old API, this should fail
try
@@ -389,6 +427,8 @@
Assert.IsTrue(stream2.AddAttribute(typeof(PayloadAttribute)) is TokenWrapper, "PayloadAttribute is implemented by TokenWrapper");
Assert.IsTrue(stream2.AddAttribute(typeof(PositionIncrementAttribute)) is TokenWrapper, "PositionIncrementAttribute is implemented by TokenWrapper");
Assert.IsTrue(stream2.AddAttribute(typeof(TypeAttribute)) is TokenWrapper, "TypeAttribute is implemented by TokenWrapper");
+ // This one is not implemented by TokenWrapper:
+ Assert.IsTrue(stream2.AddAttribute(typeof(TestTokenStreamBWComp.SenselessAttribute)) is SenselessAttributeImpl, "SenselessAttribute is not implemented by SenselessAttributeImpl");
}
finally
{
Modified: incubator/lucene.net/trunk/C#/src/Test/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/AssemblyInfo.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/AssemblyInfo.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/AssemblyInfo.cs Tue Nov 17 01:13:56 2009
@@ -16,7 +16,7 @@
[assembly: AssemblyDefaultAlias("Lucene.Net")]
[assembly: AssemblyCulture("")]
-[assembly: AssemblyInformationalVersionAttribute("2.9.0")]
+[assembly: AssemblyInformationalVersionAttribute("2.9.1")]
//
// Version information for an assembly consists of the following four values:
@@ -29,7 +29,7 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("2.9.0.001")]
+[assembly: AssemblyVersion("2.9.1.001")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
Modified: incubator/lucene.net/trunk/C#/src/Test/Index/TestBackwardsCompatibility.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Index/TestBackwardsCompatibility.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Index/TestBackwardsCompatibility.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Index/TestBackwardsCompatibility.cs Tue Nov 17 01:13:56 2009
@@ -24,6 +24,7 @@
using Field = Lucene.Net.Documents.Field;
using Directory = Lucene.Net.Store.Directory;
using FSDirectory = Lucene.Net.Store.FSDirectory;
+using CompressionTools = Lucene.Net.Documents.CompressionTools;
using IndexSearcher = Lucene.Net.Search.IndexSearcher;
using ScoreDoc = Lucene.Net.Search.ScoreDoc;
using TermQuery = Lucene.Net.Search.TermQuery;
@@ -531,6 +532,16 @@
doc.Add(new Field("utf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
doc.Add(new Field("content2", "here is more content with aaa aaa aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
doc.Add(new Field("fie\u2C77ld", "field with non-ascii name", Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+ if (id % 2 == 0)
+ {
+ doc.Add(new Field("compressed", TEXT_TO_COMPRESS, Field.Store.COMPRESS, Field.Index.NOT_ANALYZED));
+ doc.Add(new Field("compressedSize", System.Convert.ToString(TEXT_COMPRESSED_LENGTH), Field.Store.YES, Field.Index.NOT_ANALYZED));
+ }
+ else
+ {
+ doc.Add(new Field("compressed", BINARY_TO_COMPRESS, Field.Store.COMPRESS));
+ doc.Add(new Field("compressedSize", System.Convert.ToString(BINARY_COMPRESSED_LENGTH), Field.Store.YES, Field.Index.NOT_ANALYZED));
+ }
writer.AddDocument(doc);
}
@@ -598,5 +609,28 @@
{
return new System.IO.FileInfo(System.IO.Path.Combine(SupportClass.AppSettings.Get("tempDir", ""), dirName)).FullName;
}
+
+ internal const System.String TEXT_TO_COMPRESS = "this is a compressed field and should appear in 3.0 as an uncompressed field after merge";
+ // FieldSelectorResult.SIZE returns compressed size for compressed fields,
+ // which are internally handled as binary;
+ // do it in the same way like FieldsWriter, do not use
+ // CompressionTools.compressString() for compressed fields:
+ internal static int TEXT_COMPRESSED_LENGTH;
+
+ internal static readonly byte[] BINARY_TO_COMPRESS = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
+ internal static readonly int BINARY_COMPRESSED_LENGTH = CompressionTools.Compress(BINARY_TO_COMPRESS).Length;
+ static TestBackwardsCompatibility()
+ {
+ {
+ try
+ {
+ TEXT_COMPRESSED_LENGTH = CompressionTools.Compress(System.Text.Encoding.GetEncoding("UTF-8").GetBytes(TEXT_TO_COMPRESS)).Length;
+ }
+ catch (System.Exception e)
+ {
+ throw new System.SystemException();
+ }
+ }
+ }
}
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Index/TestIndexWriter.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriter.cs Tue Nov 17 01:13:56 2009
@@ -58,7 +58,7 @@
{
/// <summary> </summary>
- /// <version> $Id: TestIndexWriter.java 806847 2009-08-22 12:40:09Z uschindler $
+ /// <version> $Id: TestIndexWriter.java 831036 2009-10-29 17:15:12Z mikemccand $
/// </version>
[TestFixture]
public class TestIndexWriter:BaseTokenStreamTestCase
Modified: incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriterReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Index/TestIndexWriterReader.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriterReader.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Index/TestIndexWriterReader.cs Tue Nov 17 01:13:56 2009
@@ -198,6 +198,7 @@
// get a reader
IndexReader r1 = writer.GetReader();
+ Assert.IsTrue(r1.IsCurrent());
System.String id10 = r1.Document(10).GetField("id").StringValue();
@@ -205,18 +206,36 @@
newDoc.RemoveField("id");
newDoc.Add(new Field("id", System.Convert.ToString(8000), Field.Store.YES, Field.Index.NOT_ANALYZED));
writer.UpdateDocument(new Term("id", id10), newDoc);
+ Assert.IsFalse(r1.IsCurrent());
IndexReader r2 = writer.GetReader();
+ Assert.IsTrue(r2.IsCurrent());
Assert.AreEqual(0, Count(new Term("id", id10), r2));
Assert.AreEqual(1, Count(new Term("id", System.Convert.ToString(8000)), r2));
r1.Close();
- r2.Close();
writer.Close();
+ Assert.IsTrue(r2.IsCurrent());
IndexReader r3 = IndexReader.Open(dir1);
+ Assert.IsTrue(r3.IsCurrent());
+ Assert.IsTrue(r2.IsCurrent());
Assert.AreEqual(0, Count(new Term("id", id10), r3));
Assert.AreEqual(1, Count(new Term("id", System.Convert.ToString(8000)), r3));
+
+ writer = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ Document doc = new Document();
+ doc.Add(new Field("field", "a b c", Field.Store.NO, Field.Index.ANALYZED));
+ writer.AddDocument(doc);
+ Assert.IsTrue(r2.IsCurrent());
+ Assert.IsTrue(r3.IsCurrent());
+
+ writer.Close();
+
+ Assert.IsFalse(r2.IsCurrent());
+ Assert.IsTrue(!r3.IsCurrent());
+
+ r2.Close();
r3.Close();
dir1.Close();
@@ -245,9 +264,18 @@
CreateIndexNoClose(!optimize, "index2", writer2);
writer2.Close();
+ IndexReader r0 = writer.GetReader();
+ Assert.IsTrue(r0.IsCurrent());
writer.AddIndexesNoOptimize(new Directory[]{dir2});
+ Assert.IsFalse(r0.IsCurrent());
+ r0.Close();
IndexReader r1 = writer.GetReader();
+ Assert.IsTrue(r1.IsCurrent());
+
+ writer.Commit();
+ Assert.IsTrue(r1.IsCurrent());
+
Assert.AreEqual(200, r1.MaxDoc());
int index2df = r1.DocFreq(new Term("indexname", "index2"));
Modified: incubator/lucene.net/trunk/C#/src/Test/QueryParser/TestQueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/QueryParser/TestQueryParser.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/QueryParser/TestQueryParser.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/QueryParser/TestQueryParser.cs Tue Nov 17 01:13:56 2009
@@ -37,6 +37,7 @@
using Field = Lucene.Net.Documents.Field;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Term = Lucene.Net.Index.Term;
+using IndexReader = Lucene.Net.Index.IndexReader;
using RAMDirectory = Lucene.Net.Store.RAMDirectory;
using BooleanQuery = Lucene.Net.Search.BooleanQuery;
using FuzzyQuery = Lucene.Net.Search.FuzzyQuery;
@@ -50,7 +51,10 @@
using TermQuery = Lucene.Net.Search.TermQuery;
using TermRangeQuery = Lucene.Net.Search.TermRangeQuery;
using WildcardQuery = Lucene.Net.Search.WildcardQuery;
+using Directory = Lucene.Net.Store.Directory;
+using MockRAMDirectory = Lucene.Net.Store.MockRAMDirectory;
using LocalizedTestCase = Lucene.Net.Util.LocalizedTestCase;
+using Version = Lucene.Net.Util.Version;
namespace Lucene.Net.QueryParsers
{
@@ -1105,5 +1109,60 @@
base.TearDown();
BooleanQuery.SetMaxClauseCount(originalMaxClauses);
}
+
+ // LUCENE-2002: make sure defaults for StandardAnalyzer's
+ // enableStopPositionIncr & QueryParser's enablePosIncr
+ // "match"
+ [Test]
+ public virtual void TestPositionIncrements()
+ {
+ Directory dir = new MockRAMDirectory();
+ Analyzer a = new StandardAnalyzer(Version.LUCENE_CURRENT);
+ IndexWriter w = new IndexWriter(dir, a, IndexWriter.MaxFieldLength.UNLIMITED);
+ Document doc = new Document();
+ doc.Add(new Field("f", "the wizard of ozzy", Field.Store.NO, Field.Index.ANALYZED));
+ w.AddDocument(doc);
+ IndexReader r = w.GetReader();
+ w.Close();
+ IndexSearcher s = new IndexSearcher(r);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "f", a);
+ Query q = qp.Parse("\"wizard of ozzy\"");
+ Assert.AreEqual(1, s.Search(q, 1).totalHits);
+ r.Close();
+ dir.Close();
+ }
+
+ // LUCENE-2002: when we run javacc to regen QueryParser,
+ // we also run a replaceregexp step to fix 2 of the public
+ // ctors (change them to protected):
+ //
+ // protected QueryParser(CharStream stream)
+ //
+ // protected QueryParser(QueryParserTokenManager tm)
+ //
+ // This test is here as a safety, in case that ant step
+ // doesn't work for some reason.
+ [Test]
+ public virtual void TestProtectedCtors()
+ {
+ try
+ {
+ typeof(QueryParser).GetConstructor(new System.Type[]{typeof(CharStream)});
+ Assert.Fail("please switch public QueryParser(CharStream) to be protected");
+ }
+ catch (System.MethodAccessException nsme)
+ {
+ // expected
+ }
+ try
+ {
+ typeof(QueryParser).GetConstructor(new System.Type[]{typeof(QueryParserTokenManager)});
+ Assert.Fail("please switch public QueryParser(QueryParserTokenManager) to be protected");
+ }
+ catch (System.MethodAccessException nsme)
+ {
+ // expected
+ }
+ }
}
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/Payloads/TestPayloadNearQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/Payloads/TestPayloadNearQuery.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/Payloads/TestPayloadNearQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/Payloads/TestPayloadNearQuery.cs Tue Nov 17 01:13:56 2009
@@ -30,7 +30,6 @@
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Payload = Lucene.Net.Index.Payload;
using Term = Lucene.Net.Index.Term;
-using RAMDirectory = Lucene.Net.Store.RAMDirectory;
using DefaultSimilarity = Lucene.Net.Search.DefaultSimilarity;
using IndexSearcher = Lucene.Net.Search.IndexSearcher;
using QueryUtils = Lucene.Net.Search.QueryUtils;
@@ -38,6 +37,8 @@
using Searcher = Lucene.Net.Search.Searcher;
using TopDocs = Lucene.Net.Search.TopDocs;
using SpanQuery = Lucene.Net.Search.Spans.SpanQuery;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using SpanNearQuery = Lucene.Net.Search.Spans.SpanNearQuery;
using English = Lucene.Net.Util.English;
using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
@@ -160,6 +161,8 @@
{
Document doc = new Document();
doc.Add(new Field("field", English.IntToEnglish(i), Field.Store.YES, Field.Index.ANALYZED));
+ System.String txt = English.IntToEnglish(i) + ' ' + English.IntToEnglish(i + 1);
+ doc.Add(new Field("field2", txt, Field.Store.YES, Field.Index.ANALYZED));
writer.AddDocument(doc);
}
writer.Optimize();
@@ -207,6 +210,39 @@
}
[Test]
+ public virtual void TestPayloadNear()
+ {
+ SpanNearQuery q1, q2;
+ PayloadNearQuery query;
+ TopDocs hits;
+ // SpanNearQuery(clauses, 10000, false)
+ q1 = SpanNearQuery_Renamed("field2", "twenty two");
+ q2 = SpanNearQuery_Renamed("field2", "twenty three");
+ SpanQuery[] clauses = new SpanQuery[2];
+ clauses[0] = q1;
+ clauses[1] = q2;
+ query = new PayloadNearQuery(clauses, 10, false);
+ // System.out.println(query.toString());
+ Assert.AreEqual(12, searcher.Search(query, null, 100).totalHits);
+ /*
+ * System.out.println(hits.totalHits); for (int j = 0; j <
+ * hits.scoreDocs.length; j++) { ScoreDoc doc = hits.scoreDocs[j];
+ * System.out.println("doc: "+doc.doc+", score: "+doc.score); }
+ */
+ }
+
+ private SpanNearQuery SpanNearQuery_Renamed(System.String fieldName, System.String words)
+ {
+ System.String[] wordList = System.Text.RegularExpressions.Regex.Split(words, "[\\s]+");
+ SpanQuery[] clauses = new SpanQuery[wordList.Length];
+ for (int i = 0; i < clauses.Length; i++)
+ {
+ clauses[i] = new PayloadTermQuery(new Term(fieldName, wordList[i]), new AveragePayloadFunction());
+ }
+ return new SpanNearQuery(clauses, 10000, false);
+ }
+
+ [Test]
public virtual void TestLongerSpan()
{
PayloadNearQuery query;
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestFuzzyQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestFuzzyQuery.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestFuzzyQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestFuzzyQuery.cs Tue Nov 17 01:13:56 2009
@@ -19,13 +19,18 @@
using NUnit.Framework;
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
using IndexWriter = Lucene.Net.Index.IndexWriter;
+using IndexReader = Lucene.Net.Index.IndexReader;
using Term = Lucene.Net.Index.Term;
using RAMDirectory = Lucene.Net.Store.RAMDirectory;
using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
+using Directory = Lucene.Net.Store.Directory;
+using MockRAMDirectory = Lucene.Net.Store.MockRAMDirectory;
+using QueryParser = Lucene.Net.QueryParsers.QueryParser;
namespace Lucene.Net.Search
{
@@ -296,6 +301,45 @@
Assert.AreEqual(0, hits.Length);
}
+ [Test]
+ public virtual void TestGiga()
+ {
+
+ StandardAnalyzer analyzer = new StandardAnalyzer();
+
+ Directory index = new MockRAMDirectory();
+ IndexWriter w = new IndexWriter(index, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
+
+ AddDoc("Lucene in Action", w);
+ AddDoc("Lucene for Dummies", w);
+
+ // addDoc("Giga", w);
+ AddDoc("Giga byte", w);
+
+ AddDoc("ManagingGigabytesManagingGigabyte", w);
+ AddDoc("ManagingGigabytesManagingGigabytes", w);
+
+ AddDoc("The Art of Computer Science", w);
+ AddDoc("J. K. Rowling", w);
+ AddDoc("JK Rowling", w);
+ AddDoc("Joanne K Roling", w);
+ AddDoc("Bruce Willis", w);
+ AddDoc("Willis bruce", w);
+ AddDoc("Brute willis", w);
+ AddDoc("B. willis", w);
+ IndexReader r = w.GetReader();
+ w.Close();
+
+ Query q = new QueryParser("field", analyzer).Parse("giga~0.9");
+
+ // 3. search
+ IndexSearcher searcher = new IndexSearcher(r);
+ ScoreDoc[] hits = searcher.Search(q, 10).scoreDocs;
+ Assert.AreEqual(1, hits.Length);
+ Assert.AreEqual(searcher.Doc(hits[0].doc).Get("field"), "Giga byte");
+ r.Close();
+ }
+
private void AddDoc(System.String text, IndexWriter writer)
{
Document doc = new Document();
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery32.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestNumericRangeQuery32.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery32.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery32.cs Tue Nov 17 01:13:56 2009
@@ -143,6 +143,19 @@
Assert.AreSame(DocIdSet.EMPTY_DOCIDSET, f.GetDocIdSet(searcher.GetIndexReader()), "A exclusive range ending with Integer.MIN_VALUE should return the EMPTY_DOCIDSET instance");
}
+ [Test]
+ public virtual void TestOneMatchQuery()
+ {
+ System.Int32 tempAux = 1000;
+ System.Int32 tempAux2 = 1000;
+ NumericRangeQuery 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;
+ Assert.IsNotNull(sd);
+ Assert.AreEqual(1, sd.Length, "Score doc count");
+ }
+
private void TestLeftOpenRange(int precisionStep)
{
System.String field = "field" + precisionStep;
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery64.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestNumericRangeQuery64.cs?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery64.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestNumericRangeQuery64.cs Tue Nov 17 01:13:56 2009
@@ -32,7 +32,7 @@
namespace Lucene.Net.Search
{
- [TestFixture]
+ [TestFixture]
public class TestNumericRangeQuery64:LuceneTestCase
{
// distance of entries
@@ -149,6 +149,20 @@
Assert.AreSame(DocIdSet.EMPTY_DOCIDSET, f.GetDocIdSet(searcher.GetIndexReader()), "A exclusive range ending with Long.MIN_VALUE should return the EMPTY_DOCIDSET instance");
}
+ [Test]
+ public virtual void TestOneMatchQuery()
+ {
+ 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);
+ Assert.AreSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.GetRewriteMethod());
+ TopDocs topDocs = searcher.Search(q, noDocs);
+ ScoreDoc[] sd = topDocs.scoreDocs;
+ Assert.IsNotNull(sd);
+ Assert.AreEqual(1, sd.Length, "Score doc count");
+ }
+
private void TestLeftOpenRange(int precisionStep)
{
System.String field = "field" + precisionStep;
Added: incubator/lucene.net/trunk/C#/src/Test/Search/TestPrefixInBooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestPrefixInBooleanQuery.cs?rev=881077&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestPrefixInBooleanQuery.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestPrefixInBooleanQuery.cs Tue Nov 17 01:13:56 2009
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+using NUnit.Framework;
+
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using Term = Lucene.Net.Index.Term;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+
+namespace Lucene.Net.Search
+{
+
+ /// <summary> https://issues.apache.org/jira/browse/LUCENE-1974
+ ///
+ /// represent the bug of
+ ///
+ /// BooleanScorer.score(Collector collector, int max, int firstDocID)
+ ///
+ /// Line 273, end=8192, subScorerDocID=11378, then more got false?
+ ///
+ /// </summary>
+ [TestFixture]
+ public class TestPrefixInBooleanQuery:LuceneTestCase
+ {
+
+ private const System.String FIELD = "name";
+ private RAMDirectory directory = new RAMDirectory();
+
+ [SetUp]
+ protected internal virtual void SetUp()
+ {
+ base.SetUp();
+
+ IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+
+ for (int i = 0; i < 5137; ++i)
+ {
+ Document doc = new Document();
+ doc.Add(new Field(FIELD, "meaninglessnames", Field.Store.YES, Field.Index.NOT_ANALYZED));
+ writer.AddDocument(doc);
+ }
+ {
+ Document doc = new Document();
+ doc.Add(new Field(FIELD, "tangfulin", Field.Store.YES, Field.Index.NOT_ANALYZED));
+ writer.AddDocument(doc);
+ }
+
+ for (int i = 5138; i < 11377; ++i)
+ {
+ Document doc = new Document();
+ doc.Add(new Field(FIELD, "meaninglessnames", Field.Store.YES, Field.Index.NOT_ANALYZED));
+ writer.AddDocument(doc);
+ }
+ {
+ Document doc = new Document();
+ doc.Add(new Field(FIELD, "tangfulin", Field.Store.YES, Field.Index.NOT_ANALYZED));
+ writer.AddDocument(doc);
+ }
+
+ writer.Close();
+ }
+
+ [Test]
+ public virtual void TestPrefixQuery()
+ {
+ IndexSearcher indexSearcher = new IndexSearcher(directory, true);
+ Query query = new PrefixQuery(new Term(FIELD, "tang"));
+ Assert.AreEqual(2, indexSearcher.Search(query, null, 1000).totalHits, "Number of matched documents");
+ }
+
+ [Test]
+ public virtual void TestTermQuery()
+ {
+ IndexSearcher indexSearcher = new IndexSearcher(directory, true);
+ Query query = new TermQuery(new Term(FIELD, "tangfulin"));
+ Assert.AreEqual(2, indexSearcher.Search(query, null, 1000).totalHits, "Number of matched documents");
+ }
+
+ [Test]
+ public virtual void TestTermBooleanQuery()
+ {
+ IndexSearcher indexSearcher = new IndexSearcher(directory, true);
+ BooleanQuery query = new BooleanQuery();
+ query.Add(new TermQuery(new Term(FIELD, "tangfulin")), BooleanClause.Occur.SHOULD);
+ query.Add(new TermQuery(new Term(FIELD, "notexistnames")), BooleanClause.Occur.SHOULD);
+ Assert.AreEqual(2, indexSearcher.Search(query, null, 1000).totalHits, "Number of matched documents");
+ }
+
+ [Test]
+ public virtual void TestPrefixBooleanQuery()
+ {
+ IndexSearcher indexSearcher = new IndexSearcher(directory, true);
+ BooleanQuery query = new BooleanQuery();
+ query.Add(new PrefixQuery(new Term(FIELD, "tang")), BooleanClause.Occur.SHOULD);
+ query.Add(new TermQuery(new Term(FIELD, "notexistnames")), BooleanClause.Occur.SHOULD);
+ Assert.AreEqual(2, indexSearcher.Search(query, null, 1000).totalHits, "Number of matched documents");
+ }
+ }
+}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/C#/src/Test/Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Test.csproj?rev=881077&r1=881076&r2=881077&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Test.csproj (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Test.csproj Tue Nov 17 01:13:56 2009
@@ -74,9 +74,9 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
- <Reference Include="DemoLib">
- <Name>DemoLib</Name>
- <HintPath>..\Demo\DemoLib\bin\Release\DemoLib.dll</HintPath>
+ <Reference Include="DemoLib, Version=2.9.0.1, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\Demo\DemoLib\bin\Debug\DemoLib.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.85.5.452, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -363,6 +363,7 @@
<Compile Include="Search\TestPositionIncrement.cs" />
<Compile Include="Search\TestPositiveScoresOnlyCollector.cs" />
<Compile Include="Search\TestPrefixFilter.cs" />
+ <Compile Include="Search\TestPrefixInBooleanQuery.cs" />
<Compile Include="Search\TestPrefixQuery.cs" />
<Compile Include="Search\TestQueryTermVector.cs" />
<Compile Include="Search\TestQueryWrapperFilter.cs" />