lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [19/21] More work on Lucene.Net.Queries
Date Fri, 19 Sep 2014 14:19:52 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ba0f3c7d/src/Lucene.Net.Queries/CustomScoreProvider.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/CustomScoreProvider.cs b/src/Lucene.Net.Queries/CustomScoreProvider.cs
index 5491c86..d365695 100644
--- a/src/Lucene.Net.Queries/CustomScoreProvider.cs
+++ b/src/Lucene.Net.Queries/CustomScoreProvider.cs
@@ -1,192 +1,177 @@
-namespace org.apache.lucene.queries
-{
-
-	/*
-	 * 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.Linq;
+using Lucene.Net.Index;
+using Lucene.Net.Queries.Function;
+using Lucene.Net.Search;
+using org.apache.lucene.queries;
 
-	using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
-	using IndexReader = org.apache.lucene.index.IndexReader; // for javadocs
-	using FunctionQuery = org.apache.lucene.queries.function.FunctionQuery;
-	using Explanation = org.apache.lucene.search.Explanation;
-	using FieldCache = org.apache.lucene.search.FieldCache; // for javadocs
-
-	/// <summary>
-	/// An instance of this subclass should be returned by
-	/// <seealso cref="CustomScoreQuery#getCustomScoreProvider"/>, if you want
-	/// to modify the custom score calculation of a <seealso cref="CustomScoreQuery"/>.
-	/// <para>Since Lucene 2.9, queries operate on each segment of an index separately,
-	/// so the protected <seealso cref="#context"/> field can be used to resolve doc IDs,
-	/// as the supplied <code>doc</code> ID is per-segment and without knowledge
-	/// of the IndexReader you cannot access the document or <seealso cref="FieldCache"/>.
-	/// 
-	/// @lucene.experimental
-	/// @since 2.9.2
-	/// </para>
-	/// </summary>
-	public class CustomScoreProvider
-	{
+namespace Lucene.Net.Queries
+{
 
-	  protected internal readonly AtomicReaderContext context;
+    /*
+     * 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.
+     */
 
-	  /// <summary>
-	  /// Creates a new instance of the provider class for the given <seealso cref="IndexReader"/>.
-	  /// </summary>
-	  public CustomScoreProvider(AtomicReaderContext context)
-	  {
-		this.context = context;
-	  }
+    /// <summary>
+    /// An instance of this subclass should be returned by
+    /// <seealso cref="CustomScoreQuery#getCustomScoreProvider"/>, if you want
+    /// to modify the custom score calculation of a <seealso cref="CustomScoreQuery"/>.
+    /// <para>Since Lucene 2.9, queries operate on each segment of an index separately,
+    /// so the protected <seealso cref="#context"/> field can be used to resolve doc IDs,
+    /// as the supplied <code>doc</code> ID is per-segment and without knowledge
+    /// of the IndexReader you cannot access the document or <seealso cref="FieldCache"/>.
+    /// 
+    /// @lucene.experimental
+    /// @since 2.9.2
+    /// </para>
+    /// </summary>
+    public class CustomScoreProvider
+    {
 
-	  /// <summary>
-	  /// Compute a custom score by the subQuery score and a number of 
-	  /// <seealso cref="org.apache.lucene.queries.function.FunctionQuery"/> scores.
-	  /// <para> 
-	  /// Subclasses can override this method to modify the custom score.  
-	  /// </para>
-	  /// <para>
-	  /// If your custom scoring is different than the default herein you 
-	  /// should override at least one of the two customScore() methods.
-	  /// If the number of <seealso cref="FunctionQuery function queries"/> is always &lt; 2 it is 
-	  /// sufficient to override the other 
-	  /// <seealso cref="#customScore(int, float, float) customScore()"/> 
-	  /// method, which is simpler. 
-	  /// </para>
-	  /// <para>
-	  /// The default computation herein is a multiplication of given scores:
-	  /// <pre>
-	  ///     ModifiedScore = valSrcScore * valSrcScores[0] * valSrcScores[1] * ...
-	  /// </pre>
-	  /// 
-	  /// </para>
-	  /// </summary>
-	  /// <param name="doc"> id of scored doc. </param>
-	  /// <param name="subQueryScore"> score of that doc by the subQuery. </param>
-	  /// <param name="valSrcScores"> scores of that doc by the <seealso cref="FunctionQuery"/>. </param>
-	  /// <returns> custom score. </returns>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public float customScore(int doc, float subQueryScore, float valSrcScores[]) throws java.io.IOException
-	  public virtual float customScore(int doc, float subQueryScore, float[] valSrcScores)
-	  {
-		if (valSrcScores.Length == 1)
-		{
-		  return customScore(doc, subQueryScore, valSrcScores[0]);
-		}
-		if (valSrcScores.Length == 0)
-		{
-		  return customScore(doc, subQueryScore, 1);
-		}
-		float score = subQueryScore;
-		foreach (float valSrcScore in valSrcScores)
-		{
-		  score *= valSrcScore;
-		}
-		return score;
-	  }
+        protected internal readonly AtomicReaderContext context;
 
-	  /// <summary>
-	  /// Compute a custom score by the subQuery score and the <seealso cref="FunctionQuery"/> score.
-	  /// <para> 
-	  /// Subclasses can override this method to modify the custom score.
-	  /// </para>
-	  /// <para>
-	  /// If your custom scoring is different than the default herein you 
-	  /// should override at least one of the two customScore() methods.
-	  /// If the number of <seealso cref="FunctionQuery function queries"/> is always &lt; 2 it is 
-	  /// sufficient to override this customScore() method, which is simpler. 
-	  /// </para>
-	  /// <para>
-	  /// The default computation herein is a multiplication of the two scores:
-	  /// <pre>
-	  ///     ModifiedScore = subQueryScore * valSrcScore
-	  /// </pre>
-	  /// 
-	  /// </para>
-	  /// </summary>
-	  /// <param name="doc"> id of scored doc. </param>
-	  /// <param name="subQueryScore"> score of that doc by the subQuery. </param>
-	  /// <param name="valSrcScore"> score of that doc by the <seealso cref="FunctionQuery"/>. </param>
-	  /// <returns> custom score. </returns>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public float customScore(int doc, float subQueryScore, float valSrcScore) throws java.io.IOException
-	  public virtual float customScore(int doc, float subQueryScore, float valSrcScore)
-	  {
-		return subQueryScore * valSrcScore;
-	  }
+        /// <summary>
+        /// Creates a new instance of the provider class for the given <seealso cref="IndexReader"/>.
+        /// </summary>
+        public CustomScoreProvider(AtomicReaderContext context)
+        {
+            this.context = context;
+        }
 
-	  /// <summary>
-	  /// Explain the custom score.
-	  /// Whenever overriding <seealso cref="#customScore(int, float, float[])"/>, 
-	  /// this method should also be overridden to provide the correct explanation
-	  /// for the part of the custom scoring.
-	  /// </summary>
-	  /// <param name="doc"> doc being explained. </param>
-	  /// <param name="subQueryExpl"> explanation for the sub-query part. </param>
-	  /// <param name="valSrcExpls"> explanation for the value source part. </param>
-	  /// <returns> an explanation for the custom score </returns>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public org.apache.lucene.search.Explanation customExplain(int doc, org.apache.lucene.search.Explanation subQueryExpl, org.apache.lucene.search.Explanation valSrcExpls[]) throws java.io.IOException
-	  public virtual Explanation customExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
-	  {
-		if (valSrcExpls.Length == 1)
-		{
-		  return customExplain(doc, subQueryExpl, valSrcExpls[0]);
-		}
-		if (valSrcExpls.Length == 0)
-		{
-		  return subQueryExpl;
-		}
-		float valSrcScore = 1;
-		foreach (Explanation valSrcExpl in valSrcExpls)
-		{
-		  valSrcScore *= valSrcExpl.Value;
-		}
-		Explanation exp = new Explanation(valSrcScore * subQueryExpl.Value, "custom score: product of:");
-		exp.addDetail(subQueryExpl);
-		foreach (Explanation valSrcExpl in valSrcExpls)
-		{
-		  exp.addDetail(valSrcExpl);
-		}
-		return exp;
-	  }
+        /// <summary>
+        /// Compute a custom score by the subQuery score and a number of 
+        /// <seealso cref="FunctionQuery"/> scores.
+        /// <para> 
+        /// Subclasses can override this method to modify the custom score.  
+        /// </para>
+        /// <para>
+        /// If your custom scoring is different than the default herein you 
+        /// should override at least one of the two customScore() methods.
+        /// If the number of <seealso cref="FunctionQuery function queries"/> is always &lt; 2 it is 
+        /// sufficient to override the other 
+        /// <seealso cref="#customScore(int, float, float) customScore()"/> 
+        /// method, which is simpler. 
+        /// </para>
+        /// <para>
+        /// The default computation herein is a multiplication of given scores:
+        /// <pre>
+        ///     ModifiedScore = valSrcScore * valSrcScores[0] * valSrcScores[1] * ...
+        /// </pre>
+        /// 
+        /// </para>
+        /// </summary>
+        /// <param name="doc"> id of scored doc. </param>
+        /// <param name="subQueryScore"> score of that doc by the subQuery. </param>
+        /// <param name="valSrcScores"> scores of that doc by the <seealso cref="FunctionQuery"/>. </param>
+        /// <returns> custom score. </returns>
+        public virtual float CustomScore(int doc, float subQueryScore, float[] valSrcScores)
+        {
+            if (valSrcScores.Length == 1)
+            {
+                return CustomScore(doc, subQueryScore, valSrcScores[0]);
+            }
+            if (valSrcScores.Length == 0)
+            {
+                return CustomScore(doc, subQueryScore, 1);
+            }
+            return valSrcScores.Aggregate(subQueryScore, (current, valSrcScore) => current*valSrcScore);
+        }
 
-	  /// <summary>
-	  /// Explain the custom score.
-	  /// Whenever overriding <seealso cref="#customScore(int, float, float)"/>, 
-	  /// this method should also be overridden to provide the correct explanation
-	  /// for the part of the custom scoring.
-	  /// </summary>
-	  /// <param name="doc"> doc being explained. </param>
-	  /// <param name="subQueryExpl"> explanation for the sub-query part. </param>
-	  /// <param name="valSrcExpl"> explanation for the value source part. </param>
-	  /// <returns> an explanation for the custom score </returns>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public org.apache.lucene.search.Explanation customExplain(int doc, org.apache.lucene.search.Explanation subQueryExpl, org.apache.lucene.search.Explanation valSrcExpl) throws java.io.IOException
-	  public virtual Explanation customExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl)
-	  {
-		float valSrcScore = 1;
-		if (valSrcExpl != null)
-		{
-		  valSrcScore *= valSrcExpl.Value;
-		}
-		Explanation exp = new Explanation(valSrcScore * subQueryExpl.Value, "custom score: product of:");
-		exp.addDetail(subQueryExpl);
-		exp.addDetail(valSrcExpl);
-		return exp;
-	  }
+        /// <summary>
+        /// Compute a custom score by the subQuery score and the <seealso cref="FunctionQuery"/> score.
+        /// <para> 
+        /// Subclasses can override this method to modify the custom score.
+        /// </para>
+        /// <para>
+        /// If your custom scoring is different than the default herein you 
+        /// should override at least one of the two customScore() methods.
+        /// If the number of <seealso cref="FunctionQuery function queries"/> is always &lt; 2 it is 
+        /// sufficient to override this customScore() method, which is simpler. 
+        /// </para>
+        /// <para>
+        /// The default computation herein is a multiplication of the two scores:
+        /// <pre>
+        ///     ModifiedScore = subQueryScore * valSrcScore
+        /// </pre>
+        /// 
+        /// </para>
+        /// </summary>
+        /// <param name="doc"> id of scored doc. </param>
+        /// <param name="subQueryScore"> score of that doc by the subQuery. </param>
+        /// <param name="valSrcScore"> score of that doc by the <seealso cref="FunctionQuery"/>. </param>
+        /// <returns> custom score. </returns>
+        public virtual float CustomScore(int doc, float subQueryScore, float valSrcScore)
+        {
+            return subQueryScore * valSrcScore;
+        }
 
-	}
+        /// <summary>
+        /// Explain the custom score.
+        /// Whenever overriding <seealso cref="#customScore(int, float, float[])"/>, 
+        /// this method should also be overridden to provide the correct explanation
+        /// for the part of the custom scoring.
+        /// </summary>
+        /// <param name="doc"> doc being explained. </param>
+        /// <param name="subQueryExpl"> explanation for the sub-query part. </param>
+        /// <param name="valSrcExpls"> explanation for the value source part. </param>
+        /// <returns> an explanation for the custom score </returns>
+        public virtual Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation[] valSrcExpls)
+        {
+            if (valSrcExpls.Length == 1)
+            {
+                return CustomExplain(doc, subQueryExpl, valSrcExpls[0]);
+            }
+            if (valSrcExpls.Length == 0)
+            {
+                return subQueryExpl;
+            }
+            float valSrcScore = 1;
+            foreach (Explanation valSrcExpl in valSrcExpls)
+            {
+                valSrcScore *= valSrcExpl.Value;
+            }
+            Explanation exp = new Explanation(valSrcScore * subQueryExpl.Value, "custom score: product of:");
+            exp.AddDetail(subQueryExpl);
+            foreach (Explanation valSrcExpl in valSrcExpls)
+            {
+                exp.AddDetail(valSrcExpl);
+            }
+            return exp;
+        }
 
+        /// <summary>
+        /// Explain the custom score.
+        /// Whenever overriding <seealso cref="#customScore(int, float, float)"/>, 
+        /// this method should also be overridden to provide the correct explanation
+        /// for the part of the custom scoring.
+        /// </summary>
+        /// <param name="doc"> doc being explained. </param>
+        /// <param name="subQueryExpl"> explanation for the sub-query part. </param>
+        /// <param name="valSrcExpl"> explanation for the value source part. </param>
+        /// <returns> an explanation for the custom score </returns>
+        public virtual Explanation CustomExplain(int doc, Explanation subQueryExpl, Explanation valSrcExpl)
+        {
+            float valSrcScore = 1;
+            if (valSrcExpl != null)
+            {
+                valSrcScore *= valSrcExpl.Value;
+            }
+            Explanation exp = new Explanation(valSrcScore * subQueryExpl.Value, "custom score: product of:");
+            exp.AddDetail(subQueryExpl);
+            exp.AddDetail(valSrcExpl);
+            return exp;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ba0f3c7d/src/Lucene.Net.Queries/CustomScoreQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/CustomScoreQuery.cs b/src/Lucene.Net.Queries/CustomScoreQuery.cs
index 91c2597..016b87c 100644
--- a/src/Lucene.Net.Queries/CustomScoreQuery.cs
+++ b/src/Lucene.Net.Queries/CustomScoreQuery.cs
@@ -1,7 +1,12 @@
 using System.Collections.Generic;
 using System.Text;
+using Lucene.Net.Index;
+using Lucene.Net.Queries.Function;
+using Lucene.Net.Search;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
 
-namespace org.apache.lucene.queries
+namespace Lucene.Net.Queries
 {
 
 	/*
@@ -20,23 +25,7 @@ namespace org.apache.lucene.queries
 	 * See the License for the specific language governing permissions and
 	 * limitations under the License.
 	 */
-
-
-	using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
-	using IndexReader = org.apache.lucene.index.IndexReader;
-	using Term = org.apache.lucene.index.Term;
-	using FunctionQuery = org.apache.lucene.queries.function.FunctionQuery;
-	using ValueSource = org.apache.lucene.queries.function.ValueSource;
-	using ComplexExplanation = org.apache.lucene.search.ComplexExplanation;
-	using Explanation = org.apache.lucene.search.Explanation;
-	using Query = org.apache.lucene.search.Query;
-	using Weight = org.apache.lucene.search.Weight;
-	using Scorer = org.apache.lucene.search.Scorer;
-	using IndexSearcher = org.apache.lucene.search.IndexSearcher;
-	using Bits = org.apache.lucene.util.Bits;
-	using ToStringUtils = org.apache.lucene.util.ToStringUtils;
-
-	/// <summary>
+    /// <summary>
 	/// Query that sets document score as a programmatic function of several (sub) scores:
 	/// <ol>
 	///    <li>the score of its subQuery (any query)</li>
@@ -61,16 +50,16 @@ namespace org.apache.lucene.queries
 	  }
 
 	  /// <summary>
-	  /// Create a CustomScoreQuery over input subQuery and a <seealso cref="org.apache.lucene.queries.function.FunctionQuery"/>. </summary>
+	  /// Create a CustomScoreQuery over input subQuery and a <seealso cref="FunctionQuery"/>. </summary>
 	  /// <param name="subQuery"> the sub query whose score is being customized. Must not be null. </param>
 	  /// <param name="scoringQuery"> a value source query whose scores are used in the custom score
 	  /// computation.  This parameter is optional - it can be null. </param>
-	  public CustomScoreQuery(Query subQuery, FunctionQuery scoringQuery) : this(subQuery, scoringQuery != null ? new FunctionQuery[] {scoringQuery} : new FunctionQuery[0]); / / don't want an array that contains a single null..
+	  public CustomScoreQuery(Query subQuery, FunctionQuery scoringQuery) : this(subQuery, scoringQuery != null ? new FunctionQuery[] {scoringQuery} : new FunctionQuery[0]) // don't want an array that contains a single null..
 	  {
 	  }
 
 	  /// <summary>
-	  /// Create a CustomScoreQuery over input subQuery and a <seealso cref="org.apache.lucene.queries.function.FunctionQuery"/>. </summary>
+	  /// Create a CustomScoreQuery over input subQuery and a <seealso cref="FunctionQuery"/>. </summary>
 	  /// <param name="subQuery"> the sub query whose score is being customized. Must not be null. </param>
 	  /// <param name="scoringQueries"> value source queries whose scores are used in the custom score
 	  /// computation.  This parameter is optional - it can be null or even an empty array. </param>
@@ -85,58 +74,52 @@ namespace org.apache.lucene.queries
 	  }
 
 	  /*(non-Javadoc) @see org.apache.lucene.search.Query#rewrite(org.apache.lucene.index.IndexReader) */
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public org.apache.lucene.search.Query rewrite(org.apache.lucene.index.IndexReader reader) throws java.io.IOException
-	  public override Query rewrite(IndexReader reader)
+	  public override Query Rewrite(IndexReader reader)
 	  {
 		CustomScoreQuery clone = null;
 
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.search.Query sq = subQuery.rewrite(reader);
-		Query sq = subQuery.rewrite(reader);
+		Query sq = subQuery.Rewrite(reader);
 		if (sq != subQuery)
 		{
-		  clone = clone();
+		  clone = Clone();
 		  clone.subQuery = sq;
 		}
 
 		for (int i = 0; i < scoringQueries.Length; i++)
 		{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.search.Query v = scoringQueries[i].rewrite(reader);
-		  Query v = scoringQueries[i].rewrite(reader);
+		  Query v = scoringQueries[i].Rewrite(reader);
 		  if (v != scoringQueries[i])
 		  {
 			if (clone == null)
 			{
-				clone = clone();
+				clone = Clone();
 			}
 			clone.scoringQueries[i] = v;
 		  }
 		}
 
-		return (clone == null) ? this : clone;
+		return clone ?? this;
 	  }
 
 	  /*(non-Javadoc) @see org.apache.lucene.search.Query#extractTerms(java.util.Set) */
-	  public override void extractTerms(HashSet<Term> terms)
+	  public override void ExtractTerms(HashSet<Term> terms)
 	  {
-		subQuery.extractTerms(terms);
+		subQuery.ExtractTerms(terms);
 		foreach (Query scoringQuery in scoringQueries)
 		{
-		  scoringQuery.extractTerms(terms);
+		  scoringQuery.ExtractTerms(terms);
 		}
 	  }
 
 	  /*(non-Javadoc) @see org.apache.lucene.search.Query#clone() */
-	  public override CustomScoreQuery clone()
+	  public override CustomScoreQuery Clone()
 	  {
-		CustomScoreQuery clone = (CustomScoreQuery)base.clone();
-		clone.subQuery = subQuery.clone();
+		CustomScoreQuery clone = (CustomScoreQuery)base.Clone();
+		clone.subQuery = subQuery.Clone();
 		clone.scoringQueries = new Query[scoringQueries.Length];
 		for (int i = 0; i < scoringQueries.Length; i++)
 		{
-		  clone.scoringQueries[i] = scoringQueries[i].clone();
+		  clone.scoringQueries[i] = scoringQueries[i].Clone();
 		}
 		return clone;
 	  }
@@ -152,7 +135,7 @@ namespace org.apache.lucene.queries
 		}
 		sb.Append(")");
 		sb.Append(strict?" STRICT" : "");
-		return sb.ToString() + ToStringUtils.boost(Boost);
+		return sb.ToString() + ToStringUtils.Boost(Boost);
 	  }
 
 	  /// <summary>
@@ -183,7 +166,7 @@ namespace org.apache.lucene.queries
 	  /// Returns a hash code value for this object. </summary>
 	  public override int GetHashCode()
 	  {
-		return (this.GetType().GetHashCode() + subQuery.GetHashCode() + Arrays.GetHashCode(scoringQueries)) ^ float.floatToIntBits(Boost) ^ (strict ? 1234 : 4321);
+		return (this.GetType().GetHashCode() + subQuery.GetHashCode() + Arrays.GetHashCode(scoringQueries)) ^ Number.FloatToIntBits(Boost) ^ (strict ? 1234 : 4321);
 	  }
 
 	  /// <summary>
@@ -192,9 +175,7 @@ namespace org.apache.lucene.queries
 	  /// implementation as specified in the docs of <seealso cref="CustomScoreProvider"/>.
 	  /// @since 2.9.2
 	  /// </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: protected CustomScoreProvider getCustomScoreProvider(org.apache.lucene.index.AtomicReaderContext context) throws java.io.IOException
-	  protected internal virtual CustomScoreProvider getCustomScoreProvider(AtomicReaderContext context)
+	  protected internal virtual CustomScoreProvider GetCustomScoreProvider(AtomicReaderContext context)
 	  {
 		return new CustomScoreProvider(context);
 	  }
@@ -210,16 +191,14 @@ namespace org.apache.lucene.queries
 		internal bool qStrict;
 		internal float queryWeight;
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public CustomWeight(org.apache.lucene.search.IndexSearcher searcher) throws java.io.IOException
 		public CustomWeight(CustomScoreQuery outerInstance, IndexSearcher searcher)
 		{
 			this.outerInstance = outerInstance;
-		  this.subQueryWeight = outerInstance.subQuery.createWeight(searcher);
+		  this.subQueryWeight = outerInstance.subQuery.CreateWeight(searcher);
 		  this.valSrcWeights = new Weight[outerInstance.scoringQueries.Length];
 		  for (int i = 0; i < outerInstance.scoringQueries.Length; i++)
 		  {
-			this.valSrcWeights[i] = outerInstance.scoringQueries[i].createWeight(searcher);
+			this.valSrcWeights[i] = outerInstance.scoringQueries[i].CreateWeight(searcher);
 		  }
 		  this.qStrict = outerInstance.strict;
 		}
@@ -233,8 +212,6 @@ namespace org.apache.lucene.queries
 			}
 		}
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public float getValueForNormalization() throws java.io.IOException
 		public override float ValueForNormalization
 		{
 			get
@@ -256,33 +233,31 @@ namespace org.apache.lucene.queries
 		}
 
 		/*(non-Javadoc) @see org.apache.lucene.search.Weight#normalize(float) */
-		public override void normalize(float norm, float topLevelBoost)
+		public override void Normalize(float norm, float topLevelBoost)
 		{
 		  // note we DONT incorporate our boost, nor pass down any topLevelBoost 
 		  // (e.g. from outer BQ), as there is no guarantee that the CustomScoreProvider's 
 		  // function obeys the distributive law... it might call sqrt() on the subQuery score
 		  // or some other arbitrary function other than multiplication.
 		  // so, instead boosts are applied directly in score()
-		  subQueryWeight.normalize(norm, 1f);
+		  subQueryWeight.Normalize(norm, 1f);
 		  foreach (Weight valSrcWeight in valSrcWeights)
 		  {
 			if (qStrict)
 			{
-			  valSrcWeight.normalize(1, 1); // do not normalize the ValueSource part
+			  valSrcWeight.Normalize(1, 1); // do not normalize the ValueSource part
 			}
 			else
 			{
-			  valSrcWeight.normalize(norm, 1f);
+			  valSrcWeight.Normalize(norm, 1f);
 			}
 		  }
 		  queryWeight = topLevelBoost * Boost;
 		}
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public org.apache.lucene.search.Scorer scorer(org.apache.lucene.index.AtomicReaderContext context, org.apache.lucene.util.Bits acceptDocs) throws java.io.IOException
-		public override Scorer scorer(AtomicReaderContext context, Bits acceptDocs)
+		public override Scorer Scorer(AtomicReaderContext context, Bits acceptDocs)
 		{
-		  Scorer subQueryScorer = subQueryWeight.scorer(context, acceptDocs);
+		  Scorer subQueryScorer = subQueryWeight.Scorer(context, acceptDocs);
 		  if (subQueryScorer == null)
 		  {
 			return null;
@@ -290,24 +265,20 @@ namespace org.apache.lucene.queries
 		  Scorer[] valSrcScorers = new Scorer[valSrcWeights.Length];
 		  for (int i = 0; i < valSrcScorers.Length; i++)
 		  {
-			 valSrcScorers[i] = valSrcWeights[i].scorer(context, acceptDocs);
+			 valSrcScorers[i] = valSrcWeights[i].Scorer(context, acceptDocs);
 		  }
-		  return new CustomScorer(outerInstance, outerInstance.getCustomScoreProvider(context), this, queryWeight, subQueryScorer, valSrcScorers);
+		  return new CustomScorer(outerInstance, outerInstance.GetCustomScoreProvider(context), this, queryWeight, subQueryScorer, valSrcScorers);
 		}
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public org.apache.lucene.search.Explanation explain(org.apache.lucene.index.AtomicReaderContext context, int doc) throws java.io.IOException
-		public override Explanation explain(AtomicReaderContext context, int doc)
-		{
-		  Explanation explain = doExplain(context, doc);
-		  return explain == null ? new Explanation(0.0f, "no matching docs") : explain;
-		}
+	      public override Explanation Explain(AtomicReaderContext context, int doc)
+	      {
+	          Explanation explain = DoExplain(context, doc);
+	          return explain ?? new Explanation(0.0f, "no matching docs");
+	      }
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private org.apache.lucene.search.Explanation doExplain(org.apache.lucene.index.AtomicReaderContext info, int doc) throws java.io.IOException
-		internal virtual Explanation doExplain(AtomicReaderContext info, int doc)
+		internal virtual Explanation DoExplain(AtomicReaderContext info, int doc)
 		{
-		  Explanation subQueryExpl = subQueryWeight.explain(info, doc);
+		  Explanation subQueryExpl = subQueryWeight.Explain(info, doc);
 		  if (!subQueryExpl.Match)
 		  {
 			return subQueryExpl;
@@ -316,22 +287,21 @@ namespace org.apache.lucene.queries
 		  Explanation[] valSrcExpls = new Explanation[valSrcWeights.Length];
 		  for (int i = 0; i < valSrcWeights.Length; i++)
 		  {
-			valSrcExpls[i] = valSrcWeights[i].explain(info, doc);
+			valSrcExpls[i] = valSrcWeights[i].Explain(info, doc);
 		  }
-		  Explanation customExp = outerInstance.getCustomScoreProvider(info).customExplain(doc,subQueryExpl,valSrcExpls);
+		  Explanation customExp = outerInstance.GetCustomScoreProvider(info).CustomExplain(doc,subQueryExpl,valSrcExpls);
 		  float sc = Boost * customExp.Value;
 		  Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
-		  res.addDetail(customExp);
-		  res.addDetail(new Explanation(Boost, "queryBoost")); // actually using the q boost as q weight (== weight value)
+		  res.AddDetail(customExp);
+		  res.AddDetail(new Explanation(Boost, "queryBoost")); // actually using the q boost as q weight (== weight value)
 		  return res;
 		}
 
-		public override bool scoresDocsOutOfOrder()
+		public override bool ScoresDocsOutOfOrder()
 		{
 		  return false;
 		}
-
-	  }
+	  
 
 
 	  //=========================== S C O R E R ============================
@@ -360,77 +330,67 @@ namespace org.apache.lucene.queries
 		  this.provider = provider;
 		}
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public int nextDoc() throws java.io.IOException
-		public override int nextDoc()
+		public override int NextDoc()
 		{
-		  int doc = subQueryScorer.nextDoc();
+		  int doc = subQueryScorer.NextDoc();
 		  if (doc != NO_MORE_DOCS)
 		  {
 			foreach (Scorer valSrcScorer in valSrcScorers)
 			{
-			  valSrcScorer.advance(doc);
+			  valSrcScorer.Advance(doc);
 			}
 		  }
 		  return doc;
 		}
 
-		public override int docID()
+		public override int DocID()
 		{
-		  return subQueryScorer.docID();
+		  return subQueryScorer.DocID();
 		}
 
 		/*(non-Javadoc) @see org.apache.lucene.search.Scorer#score() */
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public float score() throws java.io.IOException
-		public override float score()
+		public override float Score()
 		{
 		  for (int i = 0; i < valSrcScorers.Length; i++)
 		  {
-			vScores[i] = valSrcScorers[i].score();
+			vScores[i] = valSrcScorers[i].Score();
 		  }
 		  return qWeight * provider.customScore(subQueryScorer.docID(), subQueryScorer.score(), vScores);
 		}
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public int freq() throws java.io.IOException
-		public override int freq()
+		public override int Freq()
 		{
-		  return subQueryScorer.freq();
+		  return subQueryScorer.Freq();
 		}
 
 		public override ICollection<ChildScorer> Children
 		{
 			get
 			{
-			  return Collections.singleton(new ChildScorer(subQueryScorer, "CUSTOM"));
+			  return Collections.Singleton(new ChildScorer(subQueryScorer, "CUSTOM"));
 			}
 		}
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public int advance(int target) throws java.io.IOException
-		public override int advance(int target)
+		public override int Advance(int target)
 		{
-		  int doc = subQueryScorer.advance(target);
+		  int doc = subQueryScorer.Advance(target);
 		  if (doc != NO_MORE_DOCS)
 		  {
 			foreach (Scorer valSrcScorer in valSrcScorers)
 			{
-			  valSrcScorer.advance(doc);
+			  valSrcScorer.Advance(doc);
 			}
 		  }
 		  return doc;
 		}
 
-		public override long cost()
+		public override long Cost()
 		{
-		  return subQueryScorer.cost();
+		  return subQueryScorer.Cost();
 		}
 	  }
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public org.apache.lucene.search.Weight createWeight(org.apache.lucene.search.IndexSearcher searcher) throws java.io.IOException
-	  public override Weight createWeight(IndexSearcher searcher)
+	  public override Weight CreateWeight(IndexSearcher searcher)
 	  {
 		return new CustomWeight(this, searcher);
 	  }
@@ -444,17 +404,7 @@ namespace org.apache.lucene.queries
 	  /// <P>
 	  /// Note: only has effect when the <seealso cref="ValueSource"/> part is not null.
 	  /// </summary>
-	  public virtual bool Strict
-	  {
-		  get
-		  {
-			return strict;
-		  }
-		  set
-		  {
-			this.strict = value;
-		  }
-	  }
+	  public virtual bool Strict { get; set; }
 
 
 	  /// <summary>
@@ -477,14 +427,13 @@ namespace org.apache.lucene.queries
 		  }
 	  }
 
-	  /// <summary>
-	  /// A short name of this query, used in <seealso cref="#toString(String)"/>.
-	  /// </summary>
-	  public virtual string name()
-	  {
-		return "custom";
+	      /// <summary>
+	      /// A short name of this query, used in <seealso cref="#toString(String)"/>.
+	      /// </summary>
+	      public virtual string Name
+	      {
+	          get { return "custom"; }
+	      }
 	  }
 
-	}
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ba0f3c7d/src/Lucene.Net.Queries/FilterClause.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/FilterClause.cs b/src/Lucene.Net.Queries/FilterClause.cs
index cbfe284..3794102 100644
--- a/src/Lucene.Net.Queries/FilterClause.cs
+++ b/src/Lucene.Net.Queries/FilterClause.cs
@@ -1,97 +1,91 @@
-namespace org.apache.lucene.queries
-{
-
-	/*
-	 * 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 Occur = org.apache.lucene.search.BooleanClause.Occur;
-	using Filter = org.apache.lucene.search.Filter;
+using Lucene.Net.Search;
 
-	/// <summary>
-	/// A Filter that wrapped with an indication of how that filter
-	/// is used when composed with another filter.
-	/// (Follows the boolean logic in BooleanClause for composition 
-	/// of queries.)
-	/// </summary>
-	public sealed class FilterClause
-	{
-
-	  private readonly Occur occur;
-	  private readonly Filter filter;
+namespace Lucene.Net.Queries
+{
 
-	  /// <summary>
-	  /// Create a new FilterClause </summary>
-	  /// <param name="filter"> A Filter object containing a BitSet </param>
-	  /// <param name="occur"> A parameter implementation indicating SHOULD, MUST or MUST NOT </param>
+    /*
+     * 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.
+     */
+    /// <summary>
+    /// A Filter that wrapped with an indication of how that filter
+    /// is used when composed with another filter.
+    /// (Follows the boolean logic in BooleanClause for composition 
+    /// of queries.)
+    /// </summary>
+    public sealed class FilterClause
+    {
 
-	  public FilterClause(Filter filter, Occur occur)
-	  {
-		this.occur = occur;
-		this.filter = filter;
-	  }
+        private readonly BooleanClause.Occur occur;
+        private readonly Filter filter;
 
-	  /// <summary>
-	  /// Returns this FilterClause's filter </summary>
-	  /// <returns> A Filter object </returns>
-	  public Filter Filter
-	  {
-		  get
-		  {
-			return filter;
-		  }
-	  }
+        /// <summary>
+        /// Create a new FilterClause </summary>
+        /// <param name="filter"> A Filter object containing a BitSet </param>
+        /// <param name="occur"> A parameter implementation indicating SHOULD, MUST or MUST NOT </param>
+        public FilterClause(Filter filter, BooleanClause.Occur occur)
+        {
+            this.occur = occur;
+            this.filter = filter;
+        }
 
-	  /// <summary>
-	  /// Returns this FilterClause's occur parameter </summary>
-	  /// <returns> An Occur object </returns>
-	  public Occur Occur
-	  {
-		  get
-		  {
-			return occur;
-		  }
-	  }
+        /// <summary>
+        /// Returns this FilterClause's filter </summary>
+        /// <returns> A Filter object </returns>
+        public Filter Filter
+        {
+            get
+            {
+                return filter;
+            }
+        }
 
-	  public override bool Equals(object o)
-	  {
-		if (o == this)
-		{
-		  return true;
-		}
-		if (o == null || !(o is FilterClause))
-		{
-		  return false;
-		}
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final FilterClause other = (FilterClause)o;
-		FilterClause other = (FilterClause)o;
-		return this.filter.Equals(other.filter) && this.occur == other.occur;
-	  }
+        /// <summary>
+        /// Returns this FilterClause's occur parameter </summary>
+        /// <returns> An Occur object </returns>
+        public BooleanClause.Occur Occur
+        {
+            get
+            {
+                return occur;
+            }
+        }
 
-	  public override int GetHashCode()
-	  {
-		return filter.GetHashCode() ^ occur.GetHashCode();
-	  }
+        public override bool Equals(object o)
+        {
+            if (o == this)
+            {
+                return true;
+            }
 
-	  public override string ToString()
-	  {
-		return occur.ToString() + filter.ToString();
-	  }
+            var other = o as FilterClause;
+            if (other == null)
+            {
+                return false;
+            }
+            return this.filter.Equals(other.filter) && this.occur == other.occur;
+        }
 
-	}
+        public override int GetHashCode()
+        {
+            return filter.GetHashCode() ^ occur.GetHashCode();
+        }
 
+        public override string ToString()
+        {
+            return occur.ToString() + filter.ToString();
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ba0f3c7d/src/Lucene.Net.Queries/Function/BoostedQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/BoostedQuery.cs b/src/Lucene.Net.Queries/Function/BoostedQuery.cs
index 928db91..369617c 100644
--- a/src/Lucene.Net.Queries/Function/BoostedQuery.cs
+++ b/src/Lucene.Net.Queries/Function/BoostedQuery.cs
@@ -1,287 +1,272 @@
 using System.Collections;
 using System.Collections.Generic;
 using System.Text;
+using Lucene.Net.Index;
+using Lucene.Net.Search;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using org.apache.lucene.queries.function;
 
-namespace org.apache.lucene.queries.function
+namespace Lucene.Net.Queries.Function
 {
 
-	/*
-	 * 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 org.apache.lucene.search;
-	using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
-	using IndexReader = org.apache.lucene.index.IndexReader;
-	using Term = org.apache.lucene.index.Term;
-	using Bits = org.apache.lucene.util.Bits;
-	using ToStringUtils = org.apache.lucene.util.ToStringUtils;
-
-
-	/// <summary>
-	/// Query that is boosted by a ValueSource
-	/// </summary>
-	// TODO: BoostedQuery and BoostingQuery in the same module? 
-	// something has to give
-	public class BoostedQuery : Query
-	{
-	  private Query q;
-	  private readonly ValueSource boostVal; // optional, can be null
-
-	  public BoostedQuery(Query subQuery, ValueSource boostVal)
-	  {
-		this.q = subQuery;
-		this.boostVal = boostVal;
-	  }
-
-	  public virtual Query Query
-	  {
-		  get
-		  {
-			  return q;
-		  }
-	  }
-	  public virtual ValueSource ValueSource
-	  {
-		  get
-		  {
-			  return boostVal;
-		  }
-	  }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public Query rewrite(org.apache.lucene.index.IndexReader reader) throws java.io.IOException
-	  public override Query rewrite(IndexReader reader)
-	  {
-		Query newQ = q.rewrite(reader);
-		if (newQ == q)
-		{
-			return this;
-		}
-		BoostedQuery bq = (BoostedQuery)this.MemberwiseClone();
-		bq.q = newQ;
-		return bq;
-	  }
-
-	  public override void extractTerms(HashSet<Term> terms)
-	  {
-		q.extractTerms(terms);
-	  }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public Weight createWeight(IndexSearcher searcher) throws java.io.IOException
-	  public override Weight createWeight(IndexSearcher searcher)
-	  {
-		return new BoostedQuery.BoostedWeight(this, searcher);
-	  }
-
-	  private class BoostedWeight : Weight
-	  {
-		  private readonly BoostedQuery outerInstance;
-
-		internal readonly IndexSearcher searcher;
-		internal Weight qWeight;
-		internal IDictionary fcontext;
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public BoostedWeight(IndexSearcher searcher) throws java.io.IOException
-		public BoostedWeight(BoostedQuery outerInstance, IndexSearcher searcher)
-		{
-			this.outerInstance = outerInstance;
-		  this.searcher = searcher;
-		  this.qWeight = outerInstance.q.createWeight(searcher);
-		  this.fcontext = ValueSource.newContext(searcher);
-		  outerInstance.boostVal.createWeight(fcontext,searcher);
-		}
-
-		public override Query Query
-		{
-			get
-			{
-			  return outerInstance;
-			}
-		}
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public float getValueForNormalization() throws java.io.IOException
-		public override float ValueForNormalization
-		{
-			get
-			{
-			  float sum = qWeight.ValueForNormalization;
-			  sum *= Boost * Boost;
-			  return sum;
-			}
-		}
-
-		public override void normalize(float norm, float topLevelBoost)
-		{
-		  topLevelBoost *= Boost;
-		  qWeight.normalize(norm, topLevelBoost);
-		}
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public Scorer scorer(org.apache.lucene.index.AtomicReaderContext context, org.apache.lucene.util.Bits acceptDocs) throws java.io.IOException
-		public override Scorer scorer(AtomicReaderContext context, Bits acceptDocs)
-		{
-		  Scorer subQueryScorer = qWeight.scorer(context, acceptDocs);
-		  if (subQueryScorer == null)
-		  {
-			return null;
-		  }
-		  return new BoostedQuery.CustomScorer(outerInstance, context, this, Boost, subQueryScorer, outerInstance.boostVal);
-		}
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public Explanation explain(org.apache.lucene.index.AtomicReaderContext readerContext, int doc) throws java.io.IOException
-		public override Explanation explain(AtomicReaderContext readerContext, int doc)
-		{
-		  Explanation subQueryExpl = qWeight.explain(readerContext,doc);
-		  if (!subQueryExpl.Match)
-		  {
-			return subQueryExpl;
-		  }
-		  FunctionValues vals = outerInstance.boostVal.getValues(fcontext, readerContext);
-		  float sc = subQueryExpl.Value * vals.floatVal(doc);
-		  Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
-		  res.addDetail(subQueryExpl);
-		  res.addDetail(vals.explain(doc));
-		  return res;
-		}
-	  }
-
-
-	  private class CustomScorer : Scorer
-	  {
-		  private readonly BoostedQuery outerInstance;
-
-		internal readonly BoostedQuery.BoostedWeight weight;
-		internal readonly float qWeight;
-		internal readonly Scorer scorer;
-		internal readonly FunctionValues vals;
-		internal readonly AtomicReaderContext readerContext;
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private CustomScorer(org.apache.lucene.index.AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs) throws java.io.IOException
-		internal CustomScorer(BoostedQuery outerInstance, AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs) : base(w)
-		{
-			this.outerInstance = outerInstance;
-		  this.weight = w;
-		  this.qWeight = qWeight;
-		  this.scorer = scorer;
-		  this.readerContext = readerContext;
-		  this.vals = vs.getValues(weight.fcontext, readerContext);
-		}
-
-		public override int docID()
-		{
-		  return scorer.docID();
-		}
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public int advance(int target) throws java.io.IOException
-		public override int advance(int target)
-		{
-		  return scorer.advance(target);
-		}
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public int nextDoc() throws java.io.IOException
-		public override int nextDoc()
-		{
-		  return scorer.nextDoc();
-		}
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public float score() throws java.io.IOException
-		public override float score()
-		{
-		  float score = qWeight * scorer.score() * vals.floatVal(scorer.docID());
-
-		  // Current Lucene priority queues can't handle NaN and -Infinity, so
-		  // map to -Float.MAX_VALUE. This conditional handles both -infinity
-		  // and NaN since comparisons with NaN are always false.
-		  return score > float.NegativeInfinity ? score : -float.MaxValue;
-		}
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public int freq() throws java.io.IOException
-		public override int freq()
-		{
-		  return scorer.freq();
-		}
-
-		public override ICollection<ChildScorer> Children
-		{
-			get
-			{
-			  return Collections.singleton(new ChildScorer(scorer, "CUSTOM"));
-			}
-		}
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public Explanation explain(int doc) throws java.io.IOException
-		public virtual Explanation explain(int doc)
-		{
-		  Explanation subQueryExpl = weight.qWeight.explain(readerContext,doc);
-		  if (!subQueryExpl.Match)
-		  {
-			return subQueryExpl;
-		  }
-		  float sc = subQueryExpl.Value * vals.floatVal(doc);
-		  Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
-		  res.addDetail(subQueryExpl);
-		  res.addDetail(vals.explain(doc));
-		  return res;
-		}
-
-		public override long cost()
-		{
-		  return scorer.cost();
-		}
-	  }
-
-
-	  public override string ToString(string field)
-	  {
-		StringBuilder sb = new StringBuilder();
-		sb.Append("boost(").Append(q.ToString(field)).Append(',').Append(boostVal).Append(')');
-		sb.Append(ToStringUtils.boost(Boost));
-		return sb.ToString();
-	  }
-
-	  public override bool Equals(object o)
-	  {
-	  if (!base.Equals(o))
-	  {
-		  return false;
-	  }
-		BoostedQuery other = (BoostedQuery)o;
-		return this.q.Equals(other.q) && this.boostVal.Equals(other.boostVal);
-	  }
-
-	  public override int GetHashCode()
-	  {
-		int h = q.GetHashCode();
-		h ^= (h << 17) | ((int)((uint)h >> 16));
-		h += boostVal.GetHashCode();
-		h ^= (h << 8) | ((int)((uint)h >> 25));
-		h += float.floatToIntBits(Boost);
-		return h;
-	  }
-
-	}
-
+    /*
+     * 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.
+     */
+    /// <summary>
+    /// Query that is boosted by a ValueSource
+    /// </summary>
+    // TODO: BoostedQuery and BoostingQuery in the same module? 
+    // something has to give
+    public class BoostedQuery : Query
+    {
+        private Query q;
+        private readonly ValueSource boostVal; // optional, can be null
+
+        public BoostedQuery(Query subQuery, ValueSource boostVal)
+        {
+            this.q = subQuery;
+            this.boostVal = boostVal;
+        }
+
+        public virtual Query Query
+        {
+            get
+            {
+                return q;
+            }
+        }
+        public virtual ValueSource ValueSource
+        {
+            get
+            {
+                return boostVal;
+            }
+        }
+    
+        public override Query Rewrite(IndexReader reader)
+        {
+            Query newQ = q.Rewrite(reader);
+            if (newQ == q)
+            {
+                return this;
+            }
+            BoostedQuery bq = (BoostedQuery)this.MemberwiseClone();
+            bq.q = newQ;
+            return bq;
+        }
+
+        public override void ExtractTerms(HashSet<Term> terms)
+        {
+            q.ExtractTerms(terms);
+        }
+
+        public override Weight CreateWeight(IndexSearcher searcher)
+        {
+            return new BoostedQuery.BoostedWeight(this, searcher);
+        }
+
+        private class BoostedWeight : Weight
+        {
+            private readonly BoostedQuery outerInstance;
+
+            internal readonly IndexSearcher searcher;
+            internal Weight qWeight;
+            internal IDictionary fcontext;
+
+            //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+            //ORIGINAL LINE: public BoostedWeight(IndexSearcher searcher) throws java.io.IOException
+            public BoostedWeight(BoostedQuery outerInstance, IndexSearcher searcher)
+            {
+                this.outerInstance = outerInstance;
+                this.searcher = searcher;
+                this.qWeight = outerInstance.q.CreateWeight(searcher);
+                this.fcontext = ValueSource.newContext(searcher);
+                outerInstance.boostVal.CreateWeight(fcontext, searcher);
+            }
+
+            public override Query Query
+            {
+                get
+                {
+                    return outerInstance;
+                }
+            }
+
+            //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+            //ORIGINAL LINE: @Override public float getValueForNormalization() throws java.io.IOException
+            public override float ValueForNormalization
+            {
+                get
+                {
+                    float sum = qWeight.ValueForNormalization;
+                    sum *= Boost * Boost;
+                    return sum;
+                }
+            }
+
+            public override void normalize(float norm, float topLevelBoost)
+            {
+                topLevelBoost *= Boost;
+                qWeight.Normalize(norm, topLevelBoost);
+            }
+
+            public override Scorer Scorer(AtomicReaderContext context, Bits acceptDocs)
+            {
+                Scorer subQueryScorer = qWeight.Scorer(context, acceptDocs);
+                if (subQueryScorer == null)
+                {
+                    return null;
+                }
+                return new BoostedQuery.CustomScorer(outerInstance, context, this, Boost, subQueryScorer, outerInstance.boostVal);
+            }
+
+            public override Explanation Explain(AtomicReaderContext readerContext, int doc)
+            {
+                Explanation subQueryExpl = qWeight.Explain(readerContext, doc);
+                if (!subQueryExpl.Match)
+                {
+                    return subQueryExpl;
+                }
+                FunctionValues vals = outerInstance.boostVal.GetValues(fcontext, readerContext);
+                float sc = subQueryExpl.Value * vals.FloatVal(doc);
+                Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
+                res.AddDetail(subQueryExpl);
+                res.AddDetail(vals.explain(doc));
+                return res;
+            }
+        }
+
+
+        private class CustomScorer : Scorer
+        {
+            private readonly BoostedQuery outerInstance;
+
+            internal readonly BoostedQuery.BoostedWeight weight;
+            internal readonly float qWeight;
+            internal readonly Scorer scorer;
+            internal readonly FunctionValues vals;
+            internal readonly AtomicReaderContext readerContext;
+
+            //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+            //ORIGINAL LINE: private CustomScorer(org.apache.lucene.index.AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs) throws java.io.IOException
+            internal CustomScorer(BoostedQuery outerInstance, AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs)
+                : base(w)
+            {
+                this.outerInstance = outerInstance;
+                this.weight = w;
+                this.qWeight = qWeight;
+                this.scorer = scorer;
+                this.readerContext = readerContext;
+                this.vals = vs.GetValues(weight.fcontext, readerContext);
+            }
+
+            public override int DocID()
+            {
+                return scorer.DocID();
+            }
+
+            //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+            //ORIGINAL LINE: @Override public int advance(int target) throws java.io.IOException
+            public override int Advance(int target)
+            {
+                return scorer.Advance(target);
+            }
+
+            //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+            //ORIGINAL LINE: @Override public int nextDoc() throws java.io.IOException
+            public override int NextDoc()
+            {
+                return scorer.NextDoc();
+            }
+
+            //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+            //ORIGINAL LINE: @Override public float score() throws java.io.IOException
+            public override float Score()
+            {
+                float score = qWeight * scorer.Score() * vals.FloatVal(scorer.DocID());
+
+                // Current Lucene priority queues can't handle NaN and -Infinity, so
+                // map to -Float.MAX_VALUE. This conditional handles both -infinity
+                // and NaN since comparisons with NaN are always false.
+                return score > float.NegativeInfinity ? score : -float.MaxValue;
+            }
+
+            public override int Freq()
+            {
+                return scorer.Freq();
+            }
+
+            public override ICollection<ChildScorer> Children
+            {
+                get
+                {
+                    return Collections.Singleton(new ChildScorer(scorer, "CUSTOM"));
+                }
+            }
+
+            //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+            //ORIGINAL LINE: public Explanation explain(int doc) throws java.io.IOException
+            public virtual Explanation explain(int doc)
+            {
+                Explanation subQueryExpl = weight.qWeight.Explain(readerContext, doc);
+                if (!subQueryExpl.Match)
+                {
+                    return subQueryExpl;
+                }
+                float sc = subQueryExpl.Value * vals.FloatVal(doc);
+                Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
+                res.AddDetail(subQueryExpl);
+                res.AddDetail(vals.explain(doc));
+                return res;
+            }
+
+            public override long Cost()
+            {
+                return scorer.Cost();
+            }
+        }
+
+
+        public override string ToString(string field)
+        {
+            StringBuilder sb = new StringBuilder();
+            sb.Append("boost(").Append(q.ToString(field)).Append(',').Append(boostVal).Append(')');
+            sb.Append(ToStringUtils.Boost(Boost));
+            return sb.ToString();
+        }
+
+        public override bool Equals(object o)
+        {
+            if (!base.Equals(o))
+            {
+                return false;
+            }
+            BoostedQuery other = (BoostedQuery)o;
+            return this.q.Equals(other.q) && this.boostVal.Equals(other.boostVal);
+        }
+
+        public override int GetHashCode()
+        {
+            int h = q.GetHashCode();
+            h ^= (h << 17) | ((int)((uint)h >> 16));
+            h += boostVal.GetHashCode();
+            h ^= (h << 8) | ((int)((uint)h >> 25));
+            h += Number.FloatToIntBits(Boost);
+            return h;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ba0f3c7d/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 1ad0517..c27ef4b 100644
--- a/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs
+++ b/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs
@@ -1,122 +1,118 @@
 using System;
+using Lucene.Net.Util.Mutable;
 
-namespace org.apache.lucene.queries.function.docvalues
+namespace Lucene.Net.Queries.Function.DocValues
 {
 
-	/*
-	 * 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 MutableValue = org.apache.lucene.util.mutable.MutableValue;
-	using MutableValueBool = org.apache.lucene.util.mutable.MutableValueBool;
-
-	/// <summary>
-	/// Abstract <seealso cref="FunctionValues"/> implementation which supports retrieving boolean values.
-	/// Implementations can control how the boolean values are loaded through <seealso cref="#boolVal(int)"/>}
-	/// </summary>
-	public abstract class BoolDocValues : FunctionValues
-	{
-	  protected internal readonly ValueSource vs;
-
-	  public BoolDocValues(ValueSource vs)
-	  {
-		this.vs = vs;
-	  }
-
-	  public override abstract bool boolVal(int doc);
-
-	  public override sbyte byteVal(int doc)
-	  {
-		return boolVal(doc) ? (sbyte)1 : (sbyte)0;
-	  }
-
-	  public override short shortVal(int doc)
-	  {
-		return boolVal(doc) ? (short)1 : (short)0;
-	  }
-
-	  public override float floatVal(int doc)
-	  {
-		return boolVal(doc) ? (float)1 : (float)0;
-	  }
-
-	  public override int intVal(int doc)
-	  {
-		return boolVal(doc) ? 1 : 0;
-	  }
-
-	  public override long longVal(int doc)
-	  {
-		return boolVal(doc) ? (long)1 : (long)0;
-	  }
-
-	  public override double doubleVal(int doc)
-	  {
-		return boolVal(doc) ? (double)1 : (double)0;
-	  }
-
-	  public override string strVal(int doc)
-	  {
-		return Convert.ToString(boolVal(doc));
-	  }
-
-	  public override object objectVal(int doc)
-	  {
-		return exists(doc) ? boolVal(doc) : null;
-	  }
-
-	  public override string ToString(int doc)
-	  {
-		return vs.description() + '=' + strVal(doc);
-	  }
-
-	  public override ValueFiller ValueFiller
-	  {
-		  get
-		  {
-			return new ValueFillerAnonymousInnerClassHelper(this);
-		  }
-	  }
-
-	  private class ValueFillerAnonymousInnerClassHelper : ValueFiller
-	  {
-		  private readonly BoolDocValues outerInstance;
-
-		  public ValueFillerAnonymousInnerClassHelper(BoolDocValues outerInstance)
-		  {
-			  this.outerInstance = outerInstance;
-			  mval = new MutableValueBool();
-		  }
-
-		  private readonly MutableValueBool mval;
-
-		  public override MutableValue Value
-		  {
-			  get
-			  {
-				return mval;
-			  }
-		  }
-
-		  public override void fillValue(int doc)
-		  {
-			mval.value = outerInstance.boolVal(doc);
-			mval.exists = outerInstance.exists(doc);
-		  }
-	  }
-	}
-
+    /*
+     * 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.
+     */
+    /// <summary>
+    /// Abstract <seealso cref="FunctionValues"/> implementation which supports retrieving boolean values.
+    /// Implementations can control how the boolean values are loaded through <seealso cref="#BoolVal(int)"/>}
+    /// </summary>
+    public abstract class BoolDocValues : FunctionValues
+    {
+        protected internal readonly ValueSource vs;
+
+        protected BoolDocValues(ValueSource vs)
+        {
+            this.vs = vs;
+        }
+
+        public override abstract bool BoolVal(int doc);
+
+        public override sbyte ByteVal(int doc)
+        {
+            return BoolVal(doc) ? (sbyte)1 : (sbyte)0;
+        }
+
+        public override short ShortVal(int doc)
+        {
+            return BoolVal(doc) ? (short)1 : (short)0;
+        }
+
+        public override float FloatVal(int doc)
+        {
+            return BoolVal(doc) ? 1f : 0f;
+        }
+
+        public override int IntVal(int doc)
+        {
+            return BoolVal(doc) ? 1 : 0;
+        }
+
+        public override long LongVal(int doc)
+        {
+            return BoolVal(doc) ? 1 : 0;
+        }
+
+        public override double DoubleVal(int doc)
+        {
+            return BoolVal(doc) ? 1d : 0d;
+        }
+
+        public override string StrVal(int doc)
+        {
+            return Convert.ToString(BoolVal(doc));
+        }
+
+        public override object ObjectVal(int doc)
+        {
+            return Exists(doc) ? BoolVal(doc) : (bool?)null;
+        }
+
+        public override string ToString(int doc)
+        {
+            return vs.Description + '=' + StrVal(doc);
+        }
+
+        public override AbstractValueFiller ValueFiller
+        {
+            get
+            {
+                return new ValueFillerAnonymousInnerClassHelper(this);
+            }
+        }
+
+        private class ValueFillerAnonymousInnerClassHelper : AbstractValueFiller
+        {
+            private readonly BoolDocValues outerInstance;
+
+            public ValueFillerAnonymousInnerClassHelper(BoolDocValues outerInstance)
+            {
+                this.outerInstance = outerInstance;
+                mval = new MutableValueBool();
+            }
+
+            private readonly MutableValueBool mval;
+
+            public override MutableValue Value
+            {
+                get
+                {
+                    return mval;
+                }
+            }
+
+            public override void FillValue(int doc)
+            {
+                mval.Value = outerInstance.BoolVal(doc);
+                mval.Exists = outerInstance.Exists(doc);
+            }
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ba0f3c7d/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 79f490c..832e921 100644
--- a/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs
+++ b/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs
@@ -1,6 +1,4 @@
-using System;
-
-/*
+/*
  * 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.
@@ -16,219 +14,202 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+using System;
+using Lucene.Net.Index;
+using Lucene.Net.Search;
+using Lucene.Net.Util;
+using Lucene.Net.Util.Mutable;
 
-namespace org.apache.lucene.queries.function.docvalues
+namespace Lucene.Net.Queries.Function.DocValues
 {
-
-	using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
-	using IndexReader = org.apache.lucene.index.IndexReader;
-	using SortedDocValues = org.apache.lucene.index.SortedDocValues;
-	using FieldCache = org.apache.lucene.search.FieldCache;
-	using BytesRef = org.apache.lucene.util.BytesRef;
-	using CharsRef = org.apache.lucene.util.CharsRef;
-	using UnicodeUtil = org.apache.lucene.util.UnicodeUtil;
-	using MutableValue = org.apache.lucene.util.mutable.MutableValue;
-	using MutableValueStr = org.apache.lucene.util.mutable.MutableValueStr;
-
-	/// <summary>
-	/// Serves as base class for FunctionValues based on DocTermsIndex.
-	/// @lucene.internal
-	/// </summary>
-	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();
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public DocTermsIndexDocValues(org.apache.lucene.queries.function.ValueSource vs, org.apache.lucene.index.AtomicReaderContext context, String field) throws java.io.IOException
-	  public DocTermsIndexDocValues(ValueSource vs, AtomicReaderContext context, string field)
-	  {
-		try
-		{
-		  termsIndex = FieldCache.DEFAULT.getTermsIndex(context.reader(), field);
-		}
-		catch (Exception e)
-		{
-		  throw new DocTermsIndexException(field, e);
-		}
-		this.vs = vs;
-	  }
-
-	  protected internal abstract string toTerm(string readableValue);
-
-	  public override bool exists(int doc)
-	  {
-		return ordVal(doc) >= 0;
-	  }
-
-	  public override int ordVal(int doc)
-	  {
-		return termsIndex.getOrd(doc);
-	  }
-
-	  public override int numOrd()
-	  {
-		return termsIndex.ValueCount;
-	  }
-
-	  public override bool bytesVal(int doc, BytesRef target)
-	  {
-		termsIndex.get(doc, target);
-		return target.length > 0;
-	  }
-
-	  public override string strVal(int doc)
-	  {
-		termsIndex.get(doc, spare);
-		if (spare.length == 0)
-		{
-		  return null;
-		}
-		UnicodeUtil.UTF8toUTF16(spare, spareChars);
-		return spareChars.ToString();
-	  }
-
-	  public override bool boolVal(int doc)
-	  {
-		return exists(doc);
-	  }
-
-	  public override abstract object objectVal(int doc); // force subclasses to override
-
-	  public override ValueSourceScorer getRangeScorer(IndexReader reader, string lowerVal, string upperVal, bool includeLower, bool includeUpper)
-	  {
-		// TODO: are lowerVal and upperVal in indexed form or not?
-		lowerVal = lowerVal == null ? null : toTerm(lowerVal);
-		upperVal = upperVal == null ? null : toTerm(upperVal);
-
-		int lower = int.MinValue;
-		if (lowerVal != null)
-		{
-		  lower = termsIndex.lookupTerm(new BytesRef(lowerVal));
-		  if (lower < 0)
-		  {
-			lower = -lower - 1;
-		  }
-		  else if (!includeLower)
-		  {
-			lower++;
-		  }
-		}
-
-		int upper = int.MaxValue;
-		if (upperVal != null)
-		{
-		  upper = termsIndex.lookupTerm(new BytesRef(upperVal));
-		  if (upper < 0)
-		  {
-			upper = -upper - 2;
-		  }
-		  else if (!includeUpper)
-		  {
-			upper--;
-		  }
-		}
-
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int ll = lower;
-		int ll = lower;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int uu = upper;
-		int uu = upper;
-
-		return new ValueSourceScorerAnonymousInnerClassHelper(this, reader, this, ll, uu);
-	  }
-
-	  private class ValueSourceScorerAnonymousInnerClassHelper : ValueSourceScorer
-	  {
-		  private readonly DocTermsIndexDocValues outerInstance;
-
-		  private int ll;
-		  private int uu;
-
-		  public ValueSourceScorerAnonymousInnerClassHelper(DocTermsIndexDocValues outerInstance, IndexReader reader, org.apache.lucene.queries.function.docvalues.DocTermsIndexDocValues this, int ll, int uu) : base(reader, this)
-		  {
-			  this.outerInstance = outerInstance;
-			  this.ll = ll;
-			  this.uu = uu;
-		  }
-
-		  public override bool matchesValue(int doc)
-		  {
-			int ord = outerInstance.termsIndex.getOrd(doc);
-			return ord >= ll && ord <= uu;
-		  }
-	  }
-
-	  public override string ToString(int doc)
-	  {
-		return vs.description() + '=' + strVal(doc);
-	  }
-
-	  public override ValueFiller ValueFiller
-	  {
-		  get
-		  {
-			return new ValueFillerAnonymousInnerClassHelper(this);
-		  }
-	  }
-
-	  private class ValueFillerAnonymousInnerClassHelper : ValueFiller
-	  {
-		  private readonly DocTermsIndexDocValues outerInstance;
-
-		  public ValueFillerAnonymousInnerClassHelper(DocTermsIndexDocValues outerInstance)
-		  {
-			  this.outerInstance = outerInstance;
-			  mval = new MutableValueStr();
-		  }
-
-		  private readonly MutableValueStr mval;
-
-		  public override MutableValue Value
-		  {
-			  get
-			  {
-				return mval;
-			  }
-		  }
-
-		  public override void fillValue(int doc)
-		  {
-			int ord = outerInstance.termsIndex.getOrd(doc);
-			if (ord == -1)
-			{
-			  mval.value.bytes = BytesRef.EMPTY_BYTES;
-			  mval.value.offset = 0;
-			  mval.value.length = 0;
-			  mval.exists = false;
-			}
-			else
-			{
-			  outerInstance.termsIndex.lookupOrd(ord, mval.value);
-			  mval.exists = true;
-			}
-		  }
-	  }
-
-	  /// <summary>
-	  /// Custom Exception to be thrown when the DocTermsIndex for a field cannot be generated
-	  /// </summary>
-	  public sealed class DocTermsIndexException : Exception
-	  {
-
-//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
-//ORIGINAL LINE: public DocTermsIndexException(final String fieldName, final RuntimeException cause)
-		public DocTermsIndexException(string fieldName, Exception cause) : base("Can't initialize DocTermsIndex to generate (function) FunctionValues for field: " + fieldName, cause)
-		{
-		}
-
-	  }
-
-
-	}
-
+    /// <summary>
+    /// Serves as base class for FunctionValues based on DocTermsIndex.
+    /// @lucene.internal
+    /// </summary>
+    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 DocTermsIndexDocValues(ValueSource vs, AtomicReaderContext context, string field)
+        {
+            try
+            {
+                termsIndex = FieldCache_Fields.DEFAULT.GetTermsIndex(context.AtomicReader, field);
+            }
+            catch (Exception e)
+            {
+                throw new DocTermsIndexException(field, e);
+            }
+            this.vs = vs;
+        }
+
+        protected internal abstract string toTerm(string readableValue);
+
+        public override bool Exists(int doc)
+        {
+            return OrdVal(doc) >= 0;
+        }
+
+        public override int OrdVal(int doc)
+        {
+            return termsIndex.GetOrd(doc);
+        }
+
+        public override int NumOrd()
+        {
+            return termsIndex.ValueCount;
+        }
+
+        public override bool BytesVal(int doc, BytesRef target)
+        {
+            termsIndex.Get(doc, target);
+            return target.Length > 0;
+        }
+
+        public override string StrVal(int doc)
+        {
+            termsIndex.Get(doc, spare);
+            if (spare.Length == 0)
+            {
+                return null;
+            }
+            UnicodeUtil.UTF8toUTF16(spare, spareChars);
+            return spareChars.ToString();
+        }
+
+        public override bool BoolVal(int doc)
+        {
+            return Exists(doc);
+        }
+
+        public override abstract object ObjectVal(int doc); // force subclasses to override
+
+        public override ValueSourceScorer GetRangeScorer(IndexReader reader, string lowerVal, string upperVal, bool includeLower, bool includeUpper)
+        {
+            // TODO: are lowerVal and upperVal in indexed form or not?
+            lowerVal = lowerVal == null ? null : toTerm(lowerVal);
+            upperVal = upperVal == null ? null : toTerm(upperVal);
+
+            int lower = int.MinValue;
+            if (lowerVal != null)
+            {
+                lower = termsIndex.LookupTerm(new BytesRef(lowerVal));
+                if (lower < 0)
+                {
+                    lower = -lower - 1;
+                }
+                else if (!includeLower)
+                {
+                    lower++;
+                }
+            }
+
+            int upper = int.MaxValue;
+            if (upperVal != null)
+            {
+                upper = termsIndex.LookupTerm(new BytesRef(upperVal));
+                if (upper < 0)
+                {
+                    upper = -upper - 2;
+                }
+                else if (!includeUpper)
+                {
+                    upper--;
+                }
+            }
+            int ll = lower;
+            int uu = upper;
+
+            return new ValueSourceScorerAnonymousInnerClassHelper(this, reader, this, ll, uu);
+        }
+
+        private class ValueSourceScorerAnonymousInnerClassHelper : ValueSourceScorer
+        {
+            private readonly DocTermsIndexDocValues outerInstance;
+
+            private int ll;
+            private int uu;
+
+            public ValueSourceScorerAnonymousInnerClassHelper(DocTermsIndexDocValues outerInstance, IndexReader reader,
+                DocTermsIndexDocValues @this, int ll, int uu)
+                : base(reader, @this)
+            {
+                this.outerInstance = outerInstance;
+                this.ll = ll;
+                this.uu = uu;
+            }
+
+            public override bool MatchesValue(int doc)
+            {
+                int ord = outerInstance.termsIndex.GetOrd(doc);
+                return ord >= ll && ord <= uu;
+            }
+        }
+
+        public override string ToString(int doc)
+        {
+            return vs.Description + '=' + StrVal(doc);
+        }
+
+        public override AbstractValueFiller ValueFiller
+        {
+            get
+            {
+                return new ValueFillerAnonymousInnerClassHelper(this);
+            }
+        }
+
+        private class ValueFillerAnonymousInnerClassHelper : AbstractValueFiller
+        {
+            private readonly DocTermsIndexDocValues outerInstance;
+
+            public ValueFillerAnonymousInnerClassHelper(DocTermsIndexDocValues outerInstance)
+            {
+                this.outerInstance = outerInstance;
+                mval = new MutableValueStr();
+            }
+
+            private readonly MutableValueStr mval;
+
+            public override MutableValue Value
+            {
+                get
+                {
+                    return mval;
+                }
+            }
+
+            public override void FillValue(int doc)
+            {
+                int ord = outerInstance.termsIndex.GetOrd(doc);
+                if (ord == -1)
+                {
+                    mval.Value.Bytes = BytesRef.EMPTY_BYTES;
+                    mval.Value.Offset = 0;
+                    mval.Value.Length = 0;
+                    mval.Exists = false;
+                }
+                else
+                {
+                    outerInstance.termsIndex.LookupOrd(ord, mval.Value);
+                    mval.Exists = true;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Custom Exception to be thrown when the DocTermsIndex for a field cannot be generated
+        /// </summary>
+        public sealed class DocTermsIndexException : Exception
+        {
+            public DocTermsIndexException(string fieldName, Exception cause)
+                : base("Can't initialize DocTermsIndex to generate (function) FunctionValues for field: " + fieldName, cause)
+            {
+            }
+        }
+    }
 }
\ No newline at end of file


Mime
View raw message