Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6C0B7200C17 for ; Fri, 27 Jan 2017 05:53:04 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6AB16160B50; Fri, 27 Jan 2017 04:53:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 438E0160B4C for ; Fri, 27 Jan 2017 05:53:02 +0100 (CET) Received: (qmail 28936 invoked by uid 500); 27 Jan 2017 04:53:00 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 28755 invoked by uid 99); 27 Jan 2017 04:52:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2017 04:52:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 20170DFF9F; Fri, 27 Jan 2017 04:52:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nightowl888@apache.org To: commits@lucenenet.apache.org Date: Fri, 27 Jan 2017 04:53:00 -0000 Message-Id: <8cf36da279a9485aab8f24ae4824d1e8@git.apache.org> In-Reply-To: <86ce4d1abdf542c2afa6cffdb6e22c91@git.apache.org> References: <86ce4d1abdf542c2afa6cffdb6e22c91@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] lucenenet git commit: Lucene.Net.Queries: member accessibility archived-at: Fri, 27 Jan 2017 04:53:04 -0000 Lucene.Net.Queries: member accessibility Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/fc457f59 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/fc457f59 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/fc457f59 Branch: refs/heads/api-work Commit: fc457f5996a005a3e6b87b4bb11bb6ef862eb4b9 Parents: 9c8e8fb Author: Shad Storhaug Authored: Fri Jan 27 10:54:43 2017 +0700 Committer: Shad Storhaug Committed: Fri Jan 27 10:54:43 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Queries/BooleanFilter.cs | 2 +- src/Lucene.Net.Queries/ChainedFilter.cs | 6 +- src/Lucene.Net.Queries/CommonTermsQuery.cs | 51 ++++---- src/Lucene.Net.Queries/CustomScoreProvider.cs | 3 +- src/Lucene.Net.Queries/CustomScoreQuery.cs | 11 +- src/Lucene.Net.Queries/FilterClause.cs | 4 +- .../Function/DocValues/BoolDocValues.cs | 4 +- .../DocValues/DocTermsIndexDocValues.cs | 20 +-- .../Function/DocValues/DoubleDocValues.cs | 4 +- .../Function/DocValues/FloatDocValues.cs | 2 +- .../Function/DocValues/IntDocValues.cs | 3 +- .../Function/DocValues/LongDocValues.cs | 5 +- .../Function/DocValues/StrDocValues.cs | 5 +- .../Function/FunctionQuery.cs | 24 ++-- .../Function/FunctionValues.cs | 25 ++-- src/Lucene.Net.Queries/Function/ValueSource.cs | 13 +- .../Function/ValueSourceScorer.cs | 10 +- .../Function/ValueSources/ByteFieldSource.cs | 1 - .../ValueSources/BytesRefFieldSource.cs | 3 +- .../Function/ValueSources/ConstNumberSource.cs | 6 +- .../Function/ValueSources/ConstValueSource.cs | 4 +- .../Function/ValueSources/DefFunction.cs | 9 ++ .../Function/ValueSources/DocFreqValueSource.cs | 8 +- .../ValueSources/DoubleConstValueSource.cs | 4 +- .../Function/ValueSources/DoubleFieldSource.cs | 4 +- .../Function/ValueSources/DualFloatFunction.cs | 6 +- .../Function/ValueSources/EnumFieldSource.cs | 14 +-- .../Function/ValueSources/FieldCacheSource.cs | 6 +- .../Function/ValueSources/FloatFieldSource.cs | 2 +- .../Function/ValueSources/IntFieldSource.cs | 2 +- .../ValueSources/JoinDocFreqValueSource.cs | 3 +- .../ValueSources/LinearFloatFunction.cs | 6 +- .../Function/ValueSources/LongFieldSource.cs | 1 - .../Function/ValueSources/MultiBoolFunction.cs | 2 +- .../Function/ValueSources/MultiFloatFunction.cs | 4 +- .../Function/ValueSources/MultiFunction.cs | 2 +- .../Function/ValueSources/NormValueSource.cs | 2 +- .../ValueSources/RangeMapFloatFunction.cs | 6 +- .../ValueSources/ReciprocalFloatFunction.cs | 8 +- .../Function/ValueSources/ScaleFloatFunction.cs | 14 ++- .../Function/ValueSources/ShortFieldSource.cs | 7 +- .../Function/ValueSources/SimpleBoolFunction.cs | 4 +- .../ValueSources/SimpleFloatFunction.cs | 3 +- .../Function/ValueSources/SingleFunction.cs | 9 +- .../Function/ValueSources/SumFloatFunction.cs | 4 +- .../ValueSources/SumTotalTermFreqValueSource.cs | 2 +- .../Function/ValueSources/VectorValueSource.cs | 2 +- src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs | 62 +++++----- src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs | 124 ++++++++++++------- src/Lucene.Net.Queries/TermFilter.cs | 1 - src/Lucene.Net.Queries/TermsFilter.cs | 6 +- 51 files changed, 293 insertions(+), 240 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/BooleanFilter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/BooleanFilter.cs b/src/Lucene.Net.Queries/BooleanFilter.cs index bf9f86e..d31da33 100644 --- a/src/Lucene.Net.Queries/BooleanFilter.cs +++ b/src/Lucene.Net.Queries/BooleanFilter.cs @@ -36,7 +36,6 @@ namespace Lucene.Net.Queries /// public class BooleanFilter : Filter, IEnumerable { - private readonly IList clauses = new List(); /// @@ -190,6 +189,7 @@ namespace Lucene.Net.Queries return buffer.Append(')').ToString(); } + // LUCENENET specific IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/ChainedFilter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/ChainedFilter.cs b/src/Lucene.Net.Queries/ChainedFilter.cs index f968f7d..ea4f7d7 100644 --- a/src/Lucene.Net.Queries/ChainedFilter.cs +++ b/src/Lucene.Net.Queries/ChainedFilter.cs @@ -39,7 +39,6 @@ namespace Lucene.Net.Queries /// public class ChainedFilter : Filter { - public const int OR = 0; public const int AND = 1; public const int ANDNOT = 2; @@ -200,9 +199,8 @@ namespace Lucene.Net.Queries return sb.ToString(); } - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - //ORIGINAL LINE: private void doChain(org.apache.lucene.util.FixedBitSet result, int logic, org.apache.lucene.search.DocIdSet dis) throws java.io.IOException - private void doChain(FixedBitSet result, int logic, DocIdSet dis) + /// + private void doChain(FixedBitSet result, int logic, DocIdSet dis) // LUCENENET TODO: Rename DoChain { if (dis is FixedBitSet) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/CommonTermsQuery.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/CommonTermsQuery.cs b/src/Lucene.Net.Queries/CommonTermsQuery.cs index 5e919ab..cd60a0b 100644 --- a/src/Lucene.Net.Queries/CommonTermsQuery.cs +++ b/src/Lucene.Net.Queries/CommonTermsQuery.cs @@ -61,14 +61,15 @@ namespace Lucene.Net.Queries * rewrite to dismax rather than boolean. Yet, this can already be subclassed * to do so. */ - protected internal readonly IList terms = new List(); - protected internal readonly bool disableCoord; - protected internal readonly float maxTermFrequency; - protected internal readonly Occur lowFreqOccur; - protected internal readonly Occur highFreqOccur; - protected internal float lowFreqBoost = 1.0f; - protected internal float highFreqBoost = 1.0f; - + protected readonly IList terms = new List(); + protected readonly bool disableCoord; + protected readonly float maxTermFrequency; + protected readonly Occur lowFreqOccur; + protected readonly Occur highFreqOccur; + protected float lowFreqBoost = 1.0f; + protected float highFreqBoost = 1.0f; + protected float lowFreqMinNrShouldMatch = 0; + protected float highFreqMinNrShouldMatch = 0; /// /// Creates a new @@ -121,8 +122,6 @@ namespace Lucene.Net.Queries this.highFreqOccur = highFreqOccur; this.lowFreqOccur = lowFreqOccur; this.maxTermFrequency = maxTermFrequency; - LowFreqMinimumNumberShouldMatch = 0; - HighFreqMinimumNumberShouldMatch = 0; } /// @@ -159,14 +158,14 @@ namespace Lucene.Net.Queries return BuildQuery(maxDoc, contextArray, queryTerms); } - protected internal virtual int CalcLowFreqMinimumNumberShouldMatch(int numOptional) + protected virtual int CalcLowFreqMinimumNumberShouldMatch(int numOptional) { - return MinNrShouldMatch(LowFreqMinimumNumberShouldMatch, numOptional); + return MinNrShouldMatch(lowFreqMinNrShouldMatch, numOptional); } - protected internal virtual int CalcHighFreqMinimumNumberShouldMatch(int numOptional) + protected virtual int CalcHighFreqMinimumNumberShouldMatch(int numOptional) { - return MinNrShouldMatch(HighFreqMinimumNumberShouldMatch, numOptional); + return MinNrShouldMatch(highFreqMinNrShouldMatch, numOptional); } private int MinNrShouldMatch(float minNrShouldMatch, int numOptional) @@ -178,7 +177,7 @@ namespace Lucene.Net.Queries return (int)Math.Round(minNrShouldMatch * numOptional); } - protected internal virtual Query BuildQuery(int maxDoc, TermContext[] contextArray, Term[] queryTerms) + protected virtual Query BuildQuery(int maxDoc, TermContext[] contextArray, Term[] queryTerms) { var lowFreq = new BooleanQuery(disableCoord); var highFreq = new BooleanQuery(disableCoord) { Boost = highFreqBoost }; @@ -297,7 +296,7 @@ namespace Lucene.Net.Queries /// for the high and low frequency query instance. The top level query will /// always disable coords. /// - public virtual bool CoordDisabled + public virtual bool CoordDisabled // LUCENENET TODO: Rename IsCoordDisabled { get { @@ -320,7 +319,11 @@ namespace Lucene.Net.Queries /// /// /// the number of optional clauses that must match - public float LowFreqMinimumNumberShouldMatch { get; set; } + public virtual float LowFreqMinimumNumberShouldMatch + { + get { return lowFreqMinNrShouldMatch; } + set { lowFreqMinNrShouldMatch = value; } + } /// @@ -338,7 +341,11 @@ namespace Lucene.Net.Queries /// /// /// the number of optional clauses that must match - public float HighFreqMinimumNumberShouldMatch { get; set; } + public virtual float HighFreqMinimumNumberShouldMatch + { + get { return highFreqMinNrShouldMatch; } + set { highFreqMinNrShouldMatch = value; } + } public override void ExtractTerms(ISet terms) @@ -393,8 +400,8 @@ namespace Lucene.Net.Queries result = prime * result + Number.FloatToIntBits(lowFreqBoost); result = prime * result + /*((lowFreqOccur == null) ? 0 :*/ lowFreqOccur.GetHashCode()/*)*/; result = prime * result + Number.FloatToIntBits(maxTermFrequency); - result = prime * result + Number.FloatToIntBits(LowFreqMinimumNumberShouldMatch); - result = prime * result + Number.FloatToIntBits(HighFreqMinimumNumberShouldMatch); + result = prime * result + Number.FloatToIntBits(lowFreqMinNrShouldMatch); + result = prime * result + Number.FloatToIntBits(highFreqMinNrShouldMatch); result = prime * result + ((terms == null) ? 0 : terms.GetValueHashCode()); return result; } @@ -438,11 +445,11 @@ namespace Lucene.Net.Queries { return false; } - if (LowFreqMinimumNumberShouldMatch != other.LowFreqMinimumNumberShouldMatch) + if (lowFreqMinNrShouldMatch != other.lowFreqMinNrShouldMatch) { return false; } - if (HighFreqMinimumNumberShouldMatch != other.HighFreqMinimumNumberShouldMatch) + if (highFreqMinNrShouldMatch != other.highFreqMinNrShouldMatch) { return false; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/CustomScoreProvider.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/CustomScoreProvider.cs b/src/Lucene.Net.Queries/CustomScoreProvider.cs index ea4d5ed..7ff1b6e 100644 --- a/src/Lucene.Net.Queries/CustomScoreProvider.cs +++ b/src/Lucene.Net.Queries/CustomScoreProvider.cs @@ -38,8 +38,7 @@ namespace Lucene.Net.Queries /// public class CustomScoreProvider { - - protected internal readonly AtomicReaderContext context; + protected readonly AtomicReaderContext context; /// /// Creates a new instance of the provider class for the given . http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/CustomScoreQuery.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/CustomScoreQuery.cs b/src/Lucene.Net.Queries/CustomScoreQuery.cs index 30ccc4d..3699d56 100644 --- a/src/Lucene.Net.Queries/CustomScoreQuery.cs +++ b/src/Lucene.Net.Queries/CustomScoreQuery.cs @@ -38,8 +38,7 @@ namespace Lucene.Net.Queries /// public class CustomScoreQuery : Query { - - internal Query subQuery; + private Query subQuery; private Query[] scoringQueries; // never null (empty array if there are no valSrcQueries). private bool strict = false; // if true, valueSource part of query does not take part in weights normalization. @@ -181,7 +180,7 @@ namespace Lucene.Net.Queries /// implementation as specified in the docs of . /// @since 2.9.2 /// - protected internal virtual CustomScoreProvider GetCustomScoreProvider(AtomicReaderContext context) + protected virtual CustomScoreProvider GetCustomScoreProvider(AtomicReaderContext context) { return new CustomScoreProvider(context); } @@ -280,7 +279,7 @@ namespace Lucene.Net.Queries return explain ?? new Explanation(0.0f, "no matching docs"); } - internal virtual Explanation DoExplain(AtomicReaderContext info, int doc) + private Explanation DoExplain(AtomicReaderContext info, int doc) { var subQueryExpl = subQueryWeight.Explain(info, doc); if (!subQueryExpl.IsMatch) @@ -410,7 +409,7 @@ namespace Lucene.Net.Queries ///

/// Note: only has effect when the part is not null. /// - public virtual bool Strict { get; set; } + public virtual bool Strict { get; set; } // LUCENENET TODO: Rename IsStrict ///

@@ -422,6 +421,7 @@ namespace Lucene.Net.Queries /// /// The scoring queries that only affect the score of CustomScoreQuery. + [WritableArray] public virtual Query[] ScoringQueries { get { return scoringQueries; } @@ -434,6 +434,5 @@ namespace Lucene.Net.Queries { get { return "custom"; } } - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/FilterClause.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/FilterClause.cs b/src/Lucene.Net.Queries/FilterClause.cs index 09e1b32..89bc8f3 100644 --- a/src/Lucene.Net.Queries/FilterClause.cs +++ b/src/Lucene.Net.Queries/FilterClause.cs @@ -27,7 +27,6 @@ namespace Lucene.Net.Queries /// public sealed class FilterClause { - private readonly Occur occur; private readonly Filter filter; @@ -75,7 +74,8 @@ namespace Lucene.Net.Queries { return false; } - return this.filter.Equals(other.filter) && this.occur == other.occur; + return this.filter.Equals(other.filter) + && this.occur == other.occur; } public override int GetHashCode() http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs index 0f14504..5303cc4 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs @@ -26,9 +26,9 @@ namespace Lucene.Net.Queries.Function.DocValues /// public abstract class BoolDocValues : FunctionValues { - protected internal readonly ValueSource vs; + protected readonly ValueSource vs; - protected BoolDocValues(ValueSource vs) + public BoolDocValues(ValueSource vs) { this.vs = vs; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs index f47c0d1..f717faa 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs @@ -28,13 +28,13 @@ namespace Lucene.Net.Queries.Function.DocValues /// public abstract class DocTermsIndexDocValues : FunctionValues { - protected internal readonly SortedDocValues termsIndex; - protected internal readonly ValueSource vs; - protected internal readonly MutableValueStr val = new MutableValueStr(); - protected internal readonly BytesRef spare = new BytesRef(); - protected internal readonly CharsRef spareChars = new CharsRef(); + protected readonly SortedDocValues termsIndex; + protected readonly ValueSource vs; + protected readonly MutableValueStr val = new MutableValueStr(); + protected readonly BytesRef spare = new BytesRef(); + protected readonly CharsRef spareChars = new CharsRef(); - protected DocTermsIndexDocValues(ValueSource vs, AtomicReaderContext context, string field) + public DocTermsIndexDocValues(ValueSource vs, AtomicReaderContext context, string field) { try { @@ -47,7 +47,7 @@ namespace Lucene.Net.Queries.Function.DocValues this.vs = vs; } - protected internal abstract string toTerm(string readableValue); + protected abstract string toTerm(string readableValue); // LUCENENET TODO: Rename ToTerm(string readableValue) public override bool Exists(int doc) { @@ -59,7 +59,7 @@ namespace Lucene.Net.Queries.Function.DocValues return termsIndex.GetOrd(doc); } - public override int NumOrd() + public override int NumOrd() // LUCENENET TODO: Make property { return termsIndex.ValueCount; } @@ -204,6 +204,10 @@ namespace Lucene.Net.Queries.Function.DocValues /// /// Custom Exception to be thrown when the DocTermsIndex for a field cannot be generated /// + // LUCENENET: All exeption classes should be marked serializable +#if FEATURE_SERIALIZABLE + [Serializable] +#endif public sealed class DocTermsIndexException : Exception { public DocTermsIndexException(string fieldName, Exception cause) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs index cca660d..3267517 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs @@ -27,9 +27,9 @@ namespace Lucene.Net.Queries.Function.DocValues /// public abstract class DoubleDocValues : FunctionValues { - protected internal readonly ValueSource vs; + protected readonly ValueSource vs; - protected DoubleDocValues(ValueSource vs) + public DoubleDocValues(ValueSource vs) { this.vs = vs; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs index e36b4d9..a7c3435 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs @@ -26,7 +26,7 @@ namespace Lucene.Net.Queries.Function.DocValues /// public abstract class FloatDocValues : FunctionValues { - protected internal readonly ValueSource vs; + protected readonly ValueSource vs; public FloatDocValues(ValueSource vs) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs index 0a5e45c..d3dea1d 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs @@ -27,7 +27,7 @@ namespace Lucene.Net.Queries.Function.DocValues /// public abstract class IntDocValues : FunctionValues { - protected internal readonly ValueSource vs; + protected readonly ValueSource vs; public IntDocValues(ValueSource vs) { @@ -173,5 +173,4 @@ namespace Lucene.Net.Queries.Function.DocValues } } } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs index 0383b48..8e42c78 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs @@ -27,9 +27,9 @@ namespace Lucene.Net.Queries.Function.DocValues /// public abstract class LongDocValues : FunctionValues { - protected internal readonly ValueSource vs; + protected readonly ValueSource vs; - protected LongDocValues(ValueSource vs) + public LongDocValues(ValueSource vs) { this.vs = vs; } @@ -183,5 +183,4 @@ namespace Lucene.Net.Queries.Function.DocValues } } } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs index fe3262c..e6b1e52 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs @@ -25,9 +25,9 @@ namespace Lucene.Net.Queries.Function.DocValues /// public abstract class StrDocValues : FunctionValues { - protected internal readonly ValueSource vs; + protected readonly ValueSource vs; - protected StrDocValues(ValueSource vs) + public StrDocValues(ValueSource vs) { this.vs = vs; } @@ -83,5 +83,4 @@ namespace Lucene.Net.Queries.Function.DocValues } } } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/FunctionQuery.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/FunctionQuery.cs b/src/Lucene.Net.Queries/Function/FunctionQuery.cs index 2ee935d..f01c981 100644 --- a/src/Lucene.Net.Queries/Function/FunctionQuery.cs +++ b/src/Lucene.Net.Queries/Function/FunctionQuery.cs @@ -34,7 +34,7 @@ namespace Lucene.Net.Queries.Function /// public class FunctionQuery : Query { - internal readonly ValueSource func; + private readonly ValueSource func; /// defines the function to be used for scoring public FunctionQuery(ValueSource func) @@ -108,20 +108,19 @@ namespace Lucene.Net.Queries.Function } } - protected internal class AllScorer : Scorer + protected class AllScorer : Scorer { private readonly FunctionQuery outerInstance; - internal readonly IndexReader reader; - internal readonly FunctionWeight weight; - internal readonly int maxDoc; - internal readonly float qWeight; - internal int doc = -1; - internal readonly FunctionValues vals; - internal readonly IBits acceptDocs; + private readonly IndexReader reader; + private readonly FunctionWeight weight; + private readonly int maxDoc; + private readonly float qWeight; + private int doc = -1; + private readonly FunctionValues vals; + private readonly IBits acceptDocs; - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - //ORIGINAL LINE: public AllScorer(org.apache.lucene.index.AtomicReaderContext context, org.apache.lucene.util.Bits acceptDocs, FunctionWeight w, float qWeight) throws java.io.IOException + /// public AllScorer(FunctionQuery outerInstance, AtomicReaderContext context, IBits acceptDocs, FunctionWeight w, float qWeight) : base(w) { @@ -224,7 +223,8 @@ namespace Lucene.Net.Queries.Function { return false; } - return Boost == other.Boost && func.Equals(other.func); + return Boost == other.Boost + && func.Equals(other.func); } /// http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/FunctionValues.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/FunctionValues.cs b/src/Lucene.Net.Queries/Function/FunctionValues.cs index 3cc23c3..fd0a431 100644 --- a/src/Lucene.Net.Queries/Function/FunctionValues.cs +++ b/src/Lucene.Net.Queries/Function/FunctionValues.cs @@ -39,28 +39,27 @@ namespace Lucene.Net.Queries.Function // want the Query carrying around big objects public abstract class FunctionValues { - public virtual sbyte ByteVal(int doc) { throw new System.NotSupportedException(); } - public virtual short ShortVal(int doc) + public virtual short ShortVal(int doc) // LUCENENET TODO: Rename Int16Val ? { throw new System.NotSupportedException(); } - public virtual float FloatVal(int doc) + public virtual float FloatVal(int doc) // LUCENENET TODO: Rename SingleVal ? { throw new System.NotSupportedException(); } - public virtual int IntVal(int doc) + public virtual int IntVal(int doc) // LUCENENET TODO: Rename Int32Val ? { throw new System.NotSupportedException(); } - public virtual long LongVal(int doc) + public virtual long LongVal(int doc) // LUCENENET TODO: Rename Int64Val ? { throw new System.NotSupportedException(); } @@ -96,7 +95,7 @@ namespace Lucene.Net.Queries.Function } /// - /// Native Java Object representation of the value + /// Native Object representation of the value public virtual object ObjectVal(int doc) { // most FunctionValues are functions, so by default return a Float() @@ -119,7 +118,7 @@ namespace Lucene.Net.Queries.Function } /// the number of unique sort ordinals this instance has - public virtual int NumOrd() + public virtual int NumOrd() // LUCENENET TODO: Make property ? { throw new System.NotSupportedException(); } @@ -134,7 +133,7 @@ namespace Lucene.Net.Queries.Function /// /// @lucene.experimental /// - public abstract class AbstractValueFiller + public abstract class AbstractValueFiller // LUCENENET TODO: Rename ValueFiller (after renaming property ValueFiller) { /// /// MutableValue will be reused across calls @@ -147,7 +146,7 @@ namespace Lucene.Net.Queries.Function /// /// @lucene.experimental - public virtual AbstractValueFiller ValueFiller + public virtual AbstractValueFiller ValueFiller // LUCENENET TODO: Make GetValueFiller() (returns new object) { get { return new ValueFillerAnonymousInnerClassHelper(this); } } @@ -181,22 +180,22 @@ namespace Lucene.Net.Queries.Function throw new System.NotSupportedException(); } - public virtual void ShortVal(int doc, short[] vals) + public virtual void ShortVal(int doc, short[] vals) // LUCENENET TODO: Rename Int16Val ? { throw new System.NotSupportedException(); } - public virtual void FloatVal(int doc, float[] vals) + public virtual void FloatVal(int doc, float[] vals) // LUCENENET TODO: Rename SingleVal ? { throw new System.NotSupportedException(); } - public virtual void IntVal(int doc, int[] vals) + public virtual void IntVal(int doc, int[] vals) // LUCENENET TODO: Rename Int32Val ? { throw new System.NotSupportedException(); } - public virtual void LongVal(int doc, long[] vals) + public virtual void LongVal(int doc, long[] vals) // LUCENENET TODO: Rename Int64Val ? { throw new System.NotSupportedException(); } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource.cs index 55f737d..100e383 100644 --- a/src/Lucene.Net.Queries/Function/ValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSource.cs @@ -33,7 +33,6 @@ namespace Lucene.Net.Queries.Function /// public abstract class ValueSource { - /// /// Gets the values for this reader and the context that was previously /// passed to CreateWeight() @@ -116,7 +115,7 @@ namespace Lucene.Net.Queries.Function { private readonly ValueSource outerInstance; - internal readonly IDictionary context; + private readonly IDictionary context; public ValueSourceComparerSource(ValueSource outerInstance, IDictionary context) { @@ -139,11 +138,11 @@ namespace Lucene.Net.Queries.Function { private readonly ValueSource outerInstance; - internal readonly double[] values; - internal FunctionValues docVals; - internal double bottom; - internal readonly IDictionary fcontext; - internal double topValue; + private readonly double[] values; + private FunctionValues docVals; + private double bottom; + private readonly IDictionary fcontext; + private double topValue; internal ValueSourceComparer(ValueSource outerInstance, IDictionary fcontext, int numHits) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs b/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs index f4818e9..cb032ea 100644 --- a/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs +++ b/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs @@ -27,11 +27,11 @@ namespace Lucene.Net.Queries.Function /// public class ValueSourceScorer : Scorer { - protected internal readonly IndexReader reader; + protected readonly IndexReader reader; private int doc = -1; - protected internal readonly int maxDoc; - protected internal readonly FunctionValues values; - protected internal bool checkDeletes; + protected readonly int maxDoc; + protected readonly FunctionValues values; + protected bool checkDeletes; private readonly IBits liveDocs; protected internal ValueSourceScorer(IndexReader reader, FunctionValues values) @@ -52,7 +52,7 @@ namespace Lucene.Net.Queries.Function } } - public virtual bool CheckDeletes + public virtual bool CheckDeletes // LUCENENET TODO: Change to SetCheckDeletes(bool checkDeletes) (has side-effect) { set { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs index d0d6e0a..df00647 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs @@ -130,5 +130,4 @@ namespace Lucene.Net.Queries.Function.ValueSources return h; } } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs index 4c65668..c5ba904 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs @@ -105,7 +105,7 @@ namespace Lucene.Net.Queries.Function.ValueSources } - protected internal override string toTerm(string readableValue) + protected override string toTerm(string readableValue) { return readableValue; } @@ -121,5 +121,4 @@ namespace Lucene.Net.Queries.Function.ValueSources } } } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs index 2f30fc6..a2f1431 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs @@ -25,9 +25,9 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public abstract class ConstNumberSource : ValueSource { - public abstract int Int { get; } - public abstract long Long { get; } - public abstract float Float { get; } + public abstract int Int { get; } // LUCENENET TODO: Rename Int32? + public abstract long Long { get; } // LUCENENET TODO: Rename Int64? + public abstract float Float { get; } // LUCENENET TODO: Rename Single? public abstract double Double { get; } //public abstract Number Number { get; } public abstract bool Bool { get; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs index 2a8c056..eb6f0b5 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs @@ -26,7 +26,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class ConstValueSource : ConstNumberSource { - internal readonly float constant; + private readonly float constant; private readonly double dv; public ConstValueSource(float constant) @@ -132,6 +132,8 @@ namespace Lucene.Net.Queries.Function.ValueSources } } + // LUCENENET NOTE: getNumber() not supported + public override bool Bool { get http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs index 3c019be..f19ae8f 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs @@ -126,6 +126,15 @@ namespace Lucene.Net.Queries.Function.ValueSources // return true if any source is exists? return valsArr.Any(vals => vals.Exists(doc)); } + + public override AbstractValueFiller ValueFiller + { + get + { + // TODO: need ValueSource.type() to determine correct type + return base.ValueFiller; + } + } } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs index 0ea9e79..070f9c5 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs @@ -122,10 +122,10 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class DocFreqValueSource : ValueSource { - protected internal readonly string field; - protected internal readonly string indexedField; - protected internal readonly string val; - protected internal readonly BytesRef indexedBytes; + protected readonly string field; + protected readonly string indexedField; + protected readonly string val; + protected readonly BytesRef indexedBytes; public DocFreqValueSource(string field, string val, string indexedField, BytesRef indexedBytes) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs index d3830f4..b995a36 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs @@ -26,7 +26,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class DoubleConstValueSource : ConstNumberSource { - internal readonly double constant; + private readonly double constant; private readonly float fv; private readonly long lv; @@ -141,6 +141,8 @@ namespace Lucene.Net.Queries.Function.ValueSources } } + // LUCENENET NOTE: getNumber() not supported + public override bool Bool { get http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs index d227d73..389d870 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs @@ -29,8 +29,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class DoubleFieldSource : FieldCacheSource { - - protected internal readonly FieldCache.IDoubleParser parser; + protected readonly FieldCache.IDoubleParser parser; public DoubleFieldSource(string field) : this(field, null) @@ -53,7 +52,6 @@ namespace Lucene.Net.Queries.Function.ValueSources var arr = cache.GetDoubles(readerContext.AtomicReader, field, parser, true); var valid = cache.GetDocsWithField(readerContext.AtomicReader, field); return new DoubleDocValuesAnonymousInnerClassHelper(this, arr, valid); - } private class DoubleDocValuesAnonymousInnerClassHelper : DoubleDocValues http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs index bc76f39..22a7481 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs @@ -28,12 +28,12 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public abstract class DualFloatFunction : ValueSource { - protected internal readonly ValueSource a; - protected internal readonly ValueSource b; + protected readonly ValueSource a; + protected readonly ValueSource b; /// the base. /// the exponent. - protected DualFloatFunction(ValueSource a, ValueSource b) + public DualFloatFunction(ValueSource a, ValueSource b) { this.a = a; this.b = b; http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs index 1429455..63099f5 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs @@ -34,11 +34,11 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class EnumFieldSource : FieldCacheSource { - internal const int DEFAULT_VALUE = -1; + private const int DEFAULT_VALUE = -1; - internal readonly FieldCache.IIntParser parser; - internal readonly IDictionary enumIntToStringMap; - internal readonly IDictionary enumStringToIntMap; + private readonly FieldCache.IIntParser parser; + private readonly IDictionary enumIntToStringMap; + private readonly IDictionary enumStringToIntMap; public EnumFieldSource(string field, FieldCache.IIntParser parser, IDictionary enumIntToStringMap, IDictionary enumStringToIntMap) : base(field) @@ -48,7 +48,7 @@ namespace Lucene.Net.Queries.Function.ValueSources this.enumStringToIntMap = enumStringToIntMap; } - private static int? TryParseInt(string valueStr) + private static int? TryParseInt(string valueStr) // LUCENENET TODO: Rename TryParseInt32 ? { int? intValue = null; try @@ -61,7 +61,7 @@ namespace Lucene.Net.Queries.Function.ValueSources return intValue; } - private string IntValueToStringValue(int? intVal) + private string IntValueToStringValue(int? intVal) // LUCENENET TODO: Rename Int32ToStringValue ? { if (intVal == null) { @@ -77,7 +77,7 @@ namespace Lucene.Net.Queries.Function.ValueSources return DEFAULT_VALUE.ToString(CultureInfo.InvariantCulture); } - private int? StringValueToIntValue(string stringVal) + private int? StringValueToIntValue(string stringVal) // LUCENENET TODO: Rename StringValueToInt32Value ? { if (stringVal == null) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs index caed9e8..d82c0fa 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs @@ -27,10 +27,10 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public abstract class FieldCacheSource : ValueSource { - protected internal readonly string field; - protected internal readonly IFieldCache cache = Search.FieldCache.DEFAULT; + protected readonly string field; + protected readonly IFieldCache cache = Search.FieldCache.DEFAULT; - protected FieldCacheSource(string field) + public FieldCacheSource(string field) { this.field = field; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs index aa48113..b09713a 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs @@ -30,7 +30,7 @@ namespace Lucene.Net.Queries.Function.ValueSources public class FloatFieldSource : FieldCacheSource { - protected internal readonly FieldCache.IFloatParser parser; + protected readonly FieldCache.IFloatParser parser; public FloatFieldSource(string field) : this(field, null) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs index ae19498..b60ae1d 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs @@ -30,7 +30,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class IntFieldSource : FieldCacheSource { - internal readonly FieldCache.IIntParser parser; + private readonly FieldCache.IIntParser parser; public IntFieldSource(string field) : this(field, null) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs index c0ca237..c822df4 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs @@ -31,10 +31,9 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class JoinDocFreqValueSource : FieldCacheSource { - public const string NAME = "joindf"; - protected internal readonly string qfield; + protected readonly string qfield; public JoinDocFreqValueSource(string field, string qfield) : base(field) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs index 5d7db1d..95235b0 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs @@ -32,9 +32,9 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class LinearFloatFunction : ValueSource { - protected internal readonly ValueSource source; - protected internal readonly float slope; - protected internal readonly float intercept; + protected readonly ValueSource source; + protected readonly float slope; + protected readonly float intercept; public LinearFloatFunction(ValueSource source, float slope, float intercept) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs index 13c934a..bae2098 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs @@ -30,7 +30,6 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class LongFieldSource : FieldCacheSource { - protected readonly FieldCache.ILongParser parser; public LongFieldSource(string field) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs index 8a1382a..e2fe91b 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs @@ -32,7 +32,7 @@ namespace Lucene.Net.Queries.Function.ValueSources { protected readonly IList sources; - protected MultiBoolFunction(IList sources) + public MultiBoolFunction(IList sources) { this.sources = sources; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs index f142d3c..d65f4e3 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs @@ -30,9 +30,9 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public abstract class MultiFloatFunction : ValueSource { - protected internal readonly ValueSource[] sources; + protected readonly ValueSource[] sources; - protected MultiFloatFunction(ValueSource[] sources) + public MultiFloatFunction(ValueSource[] sources) { this.sources = sources; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs index 76cac2c..eb3c679 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs @@ -28,7 +28,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public abstract class MultiFunction : ValueSource { - protected internal readonly IList sources; + protected readonly IList sources; protected MultiFunction(IList sources) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs index 0deca56..0e66629 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs @@ -33,7 +33,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class NormValueSource : ValueSource { - protected internal readonly string field; + protected readonly string field; public NormValueSource(string field) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs index e7f38ef..d065c22 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs @@ -122,7 +122,11 @@ namespace Lucene.Net.Queries.Function.ValueSources var other = o as RangeMapFloatFunction; if (other == null) return false; - return this.min == other.min && this.max == other.max && this.target.Equals(other.target) && this.source.Equals(other.source) && (this.defaultVal == other.defaultVal || (this.defaultVal != null && this.defaultVal.Equals(other.defaultVal))); + return this.min == other.min + && this.max == other.max + && this.target.Equals(other.target) + && this.source.Equals(other.source) + && (this.defaultVal == other.defaultVal || (this.defaultVal != null && this.defaultVal.Equals(other.defaultVal))); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs index 31c12cc..1401788 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs @@ -46,10 +46,10 @@ namespace Lucene.Net.Queries.Function.ValueSources ///
public class ReciprocalFloatFunction : ValueSource { - protected internal readonly ValueSource source; - protected internal readonly float m; - protected internal readonly float a; - protected internal readonly float b; + protected readonly ValueSource source; + protected readonly float m; + protected readonly float a; + protected readonly float b; /// /// f(source) = a/(m*float(source)+b) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs index f5226bb..d322f90 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs @@ -38,9 +38,9 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class ScaleFloatFunction : ValueSource { - protected internal readonly ValueSource source; - protected internal readonly float min; - protected internal readonly float max; + protected readonly ValueSource source; + protected readonly float min; + protected readonly float max; public ScaleFloatFunction(ValueSource source, float min, float max) { @@ -56,8 +56,8 @@ namespace Lucene.Net.Queries.Function.ValueSources private class ScaleInfo { - internal float minVal; - internal float maxVal; + internal float minVal; // LUCENENET TODO: Make property + internal float maxVal; // LUCENENET TODO: Make property } private ScaleInfo CreateScaleInfo(IDictionary context, AtomicReaderContext readerContext) @@ -169,7 +169,9 @@ namespace Lucene.Net.Queries.Function.ValueSources var other = o as ScaleFloatFunction; if (other == null) return false; - return this.min == other.min && this.max == other.max && this.source.Equals(other.source); + return this.min == other.min + && this.max == other.max + && this.source.Equals(other.source); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs index ae4580a..c3bda02 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs @@ -31,7 +31,7 @@ namespace Lucene.Net.Queries.Function.ValueSources [Obsolete] public class ShortFieldSource : FieldCacheSource { - readonly FieldCache.IShortParser parser; + private readonly FieldCache.IShortParser parser; public ShortFieldSource(string field) : this(field, null) @@ -105,7 +105,6 @@ namespace Lucene.Net.Queries.Function.ValueSources { return outerInstance.GetDescription() + '=' + ShortVal(doc); } - } public override bool Equals(object o) @@ -113,7 +112,9 @@ namespace Lucene.Net.Queries.Function.ValueSources var other = o as ShortFieldSource; if (other == null) return false; - return base.Equals(other) && (parser == null ? other.parser == null : parser.GetType() == other.parser.GetType()); + return base.Equals(other) + && (parser == null ? other.parser == null : + parser.GetType() == other.parser.GetType()); } public override int GetHashCode() http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs index 7649294..47b0549 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs @@ -30,9 +30,9 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public abstract class SimpleBoolFunction : BoolFunction { - protected internal readonly ValueSource source; + protected readonly ValueSource source; - protected SimpleBoolFunction(ValueSource source) + public SimpleBoolFunction(ValueSource source) { this.source = source; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs index f32a101..9725280 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs @@ -23,10 +23,9 @@ namespace Lucene.Net.Queries.Function.ValueSources /// /// A simple float function with a single argument /// - // LUCENENET TODO: Rename SimpleSingleFunction ? public abstract class SimpleFloatFunction : SingleFunction { - protected SimpleFloatFunction(ValueSource source) + public SimpleFloatFunction(ValueSource source) : base(source) { } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs index b1a22c9..3d94ab1 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs @@ -24,14 +24,14 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public abstract class SingleFunction : ValueSource { - protected internal readonly ValueSource source; + protected readonly ValueSource source; - protected SingleFunction(ValueSource source) + public SingleFunction(ValueSource source) { this.source = source; } - protected internal abstract string Name { get; } + protected abstract string Name { get; } public override string GetDescription() { @@ -48,7 +48,8 @@ namespace Lucene.Net.Queries.Function.ValueSources var other = o as SingleFunction; if (other == null) return false; - return Name.Equals(other.Name) && source.Equals(other.source); + return Name.Equals(other.Name) + && source.Equals(other.source); } public override void CreateWeight(IDictionary context, IndexSearcher searcher) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs index 451cca4..280612f 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs @@ -19,18 +19,16 @@ using System.Linq; namespace Lucene.Net.Queries.Function.ValueSources { - - /// /// SumFloatFunction returns the sum of it's components. /// - // LUCENENET TODO: Rename (private) public class SumFloatFunction : MultiFloatFunction { public SumFloatFunction(ValueSource[] sources) : base(sources) { } + protected override string Name { get { return "sum"; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs index e8f3c18..2b04265 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs @@ -30,7 +30,7 @@ namespace Lucene.Net.Queries.Function.ValueSources /// public class SumTotalTermFreqValueSource : ValueSource { - protected internal readonly string indexedField; + protected readonly string indexedField; public SumTotalTermFreqValueSource(string indexedField) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs index 98e8292..3146988 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs @@ -29,7 +29,7 @@ namespace Lucene.Net.Queries.Function.ValueSources //Not crazy about the name, but... public class VectorValueSource : MultiValueSource { - protected internal readonly IList sources; + protected readonly IList sources; public VectorValueSource(IList sources) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs b/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs index 24dd148..f728a81 100644 --- a/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs +++ b/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs @@ -23,6 +23,7 @@ using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Search.Similarities; +using Lucene.Net.Support; using Lucene.Net.Util; using Reader = System.IO.TextReader; @@ -131,21 +132,21 @@ namespace Lucene.Net.Queries.Mlt /// Default maximum number of tokens to parse in each example doc field that is not stored with TermVector support. /// /// - public const int DEFAULT_MAX_NUM_TOKENS_PARSED = 5000; + public static readonly int DEFAULT_MAX_NUM_TOKENS_PARSED = 5000; /// /// Ignore terms with less than this frequency in the source doc. /// /// /// - public const int DEFAULT_MIN_TERM_FREQ = 2; + public static readonly int DEFAULT_MIN_TERM_FREQ = 2; /// /// Ignore words which do not occur in at least this many docs. /// /// /// - public const int DEFAULT_MIN_DOC_FREQ = 5; + public static readonly int DEFAULT_MIN_DOC_FREQ = 5; /// /// Ignore words which occur in more than this many docs. @@ -160,7 +161,7 @@ namespace Lucene.Net.Queries.Mlt /// /// /// - public const bool DEFAULT_BOOST = false; + public static readonly bool DEFAULT_BOOST = false; /// /// Default field names. Null is used to specify that the field names should be looked @@ -173,14 +174,14 @@ namespace Lucene.Net.Queries.Mlt /// /// /// - public const int DEFAULT_MIN_WORD_LENGTH = 0; + public static readonly int DEFAULT_MIN_WORD_LENGTH = 0; /// /// Ignore words greater than this length or if 0 then this has no effect. /// /// /// - public const int DEFAULT_MAX_WORD_LENGTH = 0; + public static readonly int DEFAULT_MAX_WORD_LENGTH = 0; /// /// Default set of stopwords. @@ -188,7 +189,7 @@ namespace Lucene.Net.Queries.Mlt /// /// /// - public const ISet DEFAULT_STOP_WORDS = null; + public static readonly ISet DEFAULT_STOP_WORDS = null; /// /// Return a Query with no more than this many terms. @@ -196,7 +197,12 @@ namespace Lucene.Net.Queries.Mlt /// /// /// - public const int DEFAULT_MAX_QUERY_TERMS = 25; + public static readonly int DEFAULT_MAX_QUERY_TERMS = 25; + + // LUCNENENET NOTE: The following fields were made into auto-implemented properties: + // analyzer, minTermFreq, minDocFreq, maxDocFreq, boost, + // fieldNames, maxNumTokensParsed, minWordLen, maxWordLen, + // maxQueryTerms, similarity /// /// IndexReader to use @@ -238,8 +244,9 @@ namespace Lucene.Net.Queries.Mlt { this.ir = ir; this.Similarity = sim; - StopWords = DEFAULT_STOP_WORDS; + // LUCENENET specific: Set Defaults + StopWords = DEFAULT_STOP_WORDS; MinTermFreq = DEFAULT_MIN_TERM_FREQ; MinDocFreq = DEFAULT_MIN_DOC_FREQ; MaxDocFreq = DEFAULT_MAX_DOC_FREQ; @@ -251,7 +258,9 @@ namespace Lucene.Net.Queries.Mlt MaxQueryTerms = DEFAULT_MAX_QUERY_TERMS; } - + /// + /// For idf() calculations. + /// public TFIDFSimilarity Similarity { get; set; } @@ -296,7 +305,7 @@ namespace Lucene.Net.Queries.Mlt /// /// the maximum percentage of documents (0-100) that a term may appear /// in to be still considered relevant - public int MaxDocFreqPct + public int MaxDocFreqPct // LUCENENET TODO: Change to SetMaxDocFreqPct(int maxPercentage) { set { @@ -311,7 +320,7 @@ namespace Lucene.Net.Queries.Mlt /// /// whether to boost terms in query based on "score" or not. /// - public bool Boost { get; set; } + public bool Boost { get; set; } // LUCENENET TODO: Rename ApplyBoost ? IsBoost seems a bit odd /// @@ -319,6 +328,7 @@ namespace Lucene.Net.Queries.Mlt /// The default field names that will be used is . /// /// the field names that will be used when generating the 'More Like This' query. + [WritableArray] public string[] FieldNames { get; set; } @@ -391,7 +401,7 @@ namespace Lucene.Net.Queries.Mlt /// /// Create the More like query from a PriorityQueue /// - private Query CreateQuery(PriorityQueue q) + private Query CreateQuery(Util.PriorityQueue q) { BooleanQuery query = new BooleanQuery(); object cur; @@ -437,9 +447,8 @@ namespace Lucene.Net.Queries.Mlt /// Create a PriorityQueue from a word->tf map. /// /// a map of words keyed on the word(String) with Int objects as the values. - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - //ORIGINAL LINE: private org.apache.lucene.util.PriorityQueue createQueue(Map words) throws IOException - private PriorityQueue createQueue(IDictionary words) + /// + private Util.PriorityQueue createQueue(IDictionary words) // LUCENENET TODO: Rename CreateQueue { // have collected all words in doc and their freqs int numDocs = ir.NumDocs; @@ -490,7 +499,7 @@ namespace Lucene.Net.Queries.Mlt /// /// Describe the parameters that control how the "more like this" query is formed. /// - public string describeParams() + public string describeParams() // LUCENENET TODO: Rename DescribeParams() { StringBuilder sb = new StringBuilder(); sb.Append("\t").Append("maxQueryTerms : ").Append(MaxQueryTerms).Append("\n"); @@ -514,18 +523,13 @@ namespace Lucene.Net.Queries.Mlt /// Find words for a more-like-this query former. /// /// the id of the lucene document from which to find terms - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - //ORIGINAL LINE: public org.apache.lucene.util.PriorityQueue retrieveTerms(int docNum) throws IOException - public PriorityQueue RetrieveTerms(int docNum) + /// + public Util.PriorityQueue RetrieveTerms(int docNum) { IDictionary termFreqMap = new Dictionary(); foreach (string fieldName in FieldNames) { - //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': - //ORIGINAL LINE: final org.apache.lucene.index.Fields vectors = ir.getTermVectors(docNum); Fields vectors = ir.GetTermVectors(docNum); - //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': - //ORIGINAL LINE: final org.apache.lucene.index.Terms vector; Terms vector; if (vectors != null) { @@ -686,10 +690,9 @@ namespace Lucene.Net.Queries.Mlt /// the reader that has the content of the document /// field passed to the analyzer to use when analyzing the content /// the most interesting words in the document ordered by score, with the highest scoring, or best entry, first + /// /// - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - //ORIGINAL LINE: public org.apache.lucene.util.PriorityQueue retrieveTerms(Reader r, String fieldName) throws IOException - public PriorityQueue RetrieveTerms(Reader r, string fieldName) + public Util.PriorityQueue RetrieveTerms(Reader r, string fieldName) { IDictionary words = new Dictionary(); AddTermFrequencies(r, words, fieldName); @@ -724,7 +727,7 @@ namespace Lucene.Net.Queries.Mlt public string[] RetrieveInterestingTerms(Reader r, string fieldName) { var al = new List(MaxQueryTerms); - PriorityQueue pq = RetrieveTerms(r, fieldName); + Util.PriorityQueue pq = RetrieveTerms(r, fieldName); object cur; int lim = MaxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller... // we just want to return the top words @@ -739,7 +742,7 @@ namespace Lucene.Net.Queries.Mlt /// /// PriorityQueue that orders words by score. /// - private class FreqQ : PriorityQueue + private class FreqQ : Util.PriorityQueue { internal FreqQ(int s) : base(s) @@ -767,5 +770,4 @@ namespace Lucene.Net.Queries.Mlt } } } - } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs b/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs index a7cbd50..af91546 100644 --- a/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs +++ b/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs @@ -35,7 +35,15 @@ namespace Lucene.Net.Queries.Mlt /// public class MoreLikeThisQuery : Query { + private string likeText; + private string[] moreLikeFields; + private Analyzer analyzer; private readonly string fieldName; + private float percentTermsToMatch = 0.3f; + private int minTermFrequency = 1; + private int maxQueryTerms = 5; + private ISet stopWords = null; + private int minDocFreq = -1; /// fields used for similarity measure public MoreLikeThisQuery(string likeText, string[] moreLikeFields, Analyzer analyzer, string fieldName) @@ -44,28 +52,27 @@ namespace Lucene.Net.Queries.Mlt this.MoreLikeFields = moreLikeFields; this.Analyzer = analyzer; this.fieldName = fieldName; - StopWords = null; - - PercentTermsToMatch = 0.3f; - MinTermFrequency = 1; - MaxQueryTerms = 5; - MinDocFreq = -1; } public override Query Rewrite(IndexReader reader) { - var mlt = new MoreLikeThis(reader) { FieldNames = MoreLikeFields, Analyzer = Analyzer, MinTermFreq = MinTermFrequency }; + var mlt = new MoreLikeThis(reader) + { + FieldNames = moreLikeFields, + Analyzer = analyzer, + MinTermFreq = minTermFrequency + }; if (MinDocFreq >= 0) { - mlt.MinDocFreq = MinDocFreq; + mlt.MinDocFreq = minDocFreq; } - mlt.MaxQueryTerms = MaxQueryTerms; - mlt.StopWords = StopWords; - var bq = (BooleanQuery)mlt.Like(new StringReader(LikeText), fieldName); + mlt.MaxQueryTerms = maxQueryTerms; + mlt.StopWords = stopWords; + var bq = (BooleanQuery)mlt.Like(new StringReader(likeText), fieldName); var clauses = bq.GetClauses(); //make at least half the terms match - bq.MinimumNumberShouldMatch = (int)(clauses.Length * PercentTermsToMatch); + bq.MinimumNumberShouldMatch = (int)(clauses.Length * percentTermsToMatch); return bq; } @@ -77,35 +84,68 @@ namespace Lucene.Net.Queries.Mlt return "like:" + LikeText; } - public float PercentTermsToMatch { get; set; } + public virtual float PercentTermsToMatch + { + get { return percentTermsToMatch; } + set { percentTermsToMatch = value; } + } - public Analyzer Analyzer { get; set; } + public virtual Analyzer Analyzer + { + get { return analyzer; } + set { analyzer = value; } + } - public string LikeText { get; set; } + public virtual string LikeText + { + get { return likeText; } + set { likeText = value; } + } - public int MaxQueryTerms { get; set; } + public virtual int MaxQueryTerms + { + get { return maxQueryTerms; } + set { maxQueryTerms = value; } + } - public int MinTermFrequency { get; set; } + public virtual int MinTermFrequency + { + get { return minTermFrequency; } + set { minTermFrequency = value; } + } - public string[] MoreLikeFields { get; set; } + [WritableArray] + public virtual string[] MoreLikeFields + { + get { return moreLikeFields; } + set { moreLikeFields = value; } + } - public ISet StopWords { get; set; } + public virtual ISet StopWords + { + get { return stopWords; } + set { stopWords = value; } + } - public int MinDocFreq { get; set; } + public virtual int MinDocFreq + { + get { return minDocFreq; } + set { minDocFreq = value; } + } public override int GetHashCode() { const int prime = 31; int result = base.GetHashCode(); - result = prime * result + ((Analyzer == null) ? 0 : Analyzer.GetHashCode()); + result = prime * result + ((analyzer == null) ? 0 : analyzer.GetHashCode()); result = prime * result + ((fieldName == null) ? 0 : fieldName.GetHashCode()); - result = prime * result + ((LikeText == null) ? 0 : LikeText.GetHashCode()); - result = prime * result + MaxQueryTerms; - result = prime * result + MinDocFreq; - result = prime * result + MinTermFrequency; - result = prime * result + Arrays.GetHashCode(MoreLikeFields); - result = prime * result + Number.FloatToIntBits(PercentTermsToMatch); - result = prime * result + ((StopWords == null) ? 0 : StopWords.GetHashCode()); + result = prime * result + ((likeText == null) ? 0 : likeText.GetHashCode()); + result = prime * result + maxQueryTerms; + result = prime * result + minDocFreq; + result = prime * result + minTermFrequency; + result = prime * result + Arrays.GetHashCode(moreLikeFields); + result = prime * result + Number.FloatToIntBits(percentTermsToMatch); + result = prime * result + ((stopWords == null) ? 0 : stopWords.GetValueHashCode()); return result; } @@ -124,14 +164,14 @@ namespace Lucene.Net.Queries.Mlt return false; } var other = (MoreLikeThisQuery)obj; - if (Analyzer == null) + if (analyzer == null) { - if (other.Analyzer != null) + if (other.analyzer != null) { return false; } } - else if (!Analyzer.Equals(other.Analyzer)) + else if (!analyzer.Equals(other.analyzer)) { return false; } @@ -146,45 +186,45 @@ namespace Lucene.Net.Queries.Mlt { return false; } - if (LikeText == null) + if (likeText == null) { - if (other.LikeText != null) + if (other.likeText != null) { return false; } } - else if (!LikeText.Equals(other.LikeText)) + else if (!likeText.Equals(other.likeText)) { return false; } - if (MaxQueryTerms != other.MaxQueryTerms) + if (maxQueryTerms != other.maxQueryTerms) { return false; } - if (MinDocFreq != other.MinDocFreq) + if (minDocFreq != other.minDocFreq) { return false; } - if (MinTermFrequency != other.MinTermFrequency) + if (minTermFrequency != other.minTermFrequency) { return false; } - if (!Arrays.Equals(MoreLikeFields, other.MoreLikeFields)) + if (!Arrays.Equals(moreLikeFields, other.moreLikeFields)) { return false; } - if (Number.FloatToIntBits(PercentTermsToMatch) != Number.FloatToIntBits(other.PercentTermsToMatch)) + if (Number.FloatToIntBits(percentTermsToMatch) != Number.FloatToIntBits(other.percentTermsToMatch)) { return false; } - if (StopWords == null) + if (stopWords == null) { - if (other.StopWords != null) + if (other.stopWords != null) { return false; } } - else if (!StopWords.Equals(other.StopWords)) + else if (!stopWords.Equals(other.stopWords)) { return false; } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/TermFilter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/TermFilter.cs b/src/Lucene.Net.Queries/TermFilter.cs index 74d3353..3f5e394 100644 --- a/src/Lucene.Net.Queries/TermFilter.cs +++ b/src/Lucene.Net.Queries/TermFilter.cs @@ -26,7 +26,6 @@ namespace Lucene.Net.Queries /// public sealed class TermFilter : Filter { - private readonly Term term; /// The term documents need to have in order to be a match for this filter. http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fc457f59/src/Lucene.Net.Queries/TermsFilter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/TermsFilter.cs b/src/Lucene.Net.Queries/TermsFilter.cs index 0b944d4..b70af95 100644 --- a/src/Lucene.Net.Queries/TermsFilter.cs +++ b/src/Lucene.Net.Queries/TermsFilter.cs @@ -35,7 +35,6 @@ namespace Lucene.Net.Queries /// public sealed class TermsFilter : Filter { - /* * this class is often used for large number of terms in a single field. * to optimize for this case and to be filter-cache friendly we @@ -218,7 +217,6 @@ namespace Lucene.Net.Queries this.termsBytes = ArrayUtil.Shrink(serializedTerms, lastEndOffset); this.termsAndFields = termsAndFields.ToArray(); this.hashCode_Renamed = hash; - } public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) @@ -394,11 +392,11 @@ namespace Lucene.Net.Queries public abstract BytesRef Next(); - protected FieldAndTermEnum() + public FieldAndTermEnum() { } - protected FieldAndTermEnum(string field) + public FieldAndTermEnum(string field) { this.field = field; }