You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/08/13 16:33:33 UTC

[1/5] lucenenet git commit: Deleted Support\OS.cs from Lucene.Net.csproj

Repository: lucenenet
Updated Branches:
  refs/heads/master c14c27e76 -> c22ef079b


Deleted Support\OS.cs from Lucene.Net.csproj


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/729ce5b9
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/729ce5b9
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/729ce5b9

Branch: refs/heads/master
Commit: 729ce5b9216ab519eb2e764ae7503ea36460fc78
Parents: c14c27e
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sat Aug 12 17:27:48 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sat Aug 12 17:27:48 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Lucene.Net.csproj | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/729ce5b9/src/Lucene.Net/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj
index 368597a..aaa3c7b 100644
--- a/src/Lucene.Net/Lucene.Net.csproj
+++ b/src/Lucene.Net/Lucene.Net.csproj
@@ -723,7 +723,6 @@
     <Compile Include="Support\IO\Compression\Inflater.cs" />
     <Compile Include="Support\Threading\IThreadRunnable.cs" />
     <Compile Include="Support\Number.cs" />
-    <Compile Include="Support\OS.cs" />
     <Compile Include="Support\IO\Compression\SharpZipLib.cs" />
     <Compile Include="Support\Threading\ThreadClass.cs" />
     <Compile Include="Support\Threading\ThreadLock.cs" />


[3/5] lucenenet git commit: API: Lucene.Net.Documents.Field: Added similar Number value types as in Java so the numeric types can be stored as object without boxing/unboxing. Also added overloads for numeric GetXXXValue() fields to IIndexableField so the

Posted by ni...@apache.org.
API: Lucene.Net.Documents.Field: Added similar Number value types as in Java so the numeric types can be stored as object without boxing/unboxing. Also added overloads for numeric GetXXXValue() fields to IIndexableField so these values can be retrieved without boxing/unboxing.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/beb4894f
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/beb4894f
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/beb4894f

Branch: refs/heads/master
Commit: beb4894f85bab7750b98c36dbe33e195011617f2
Parents: 361ceb6
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sun Aug 13 00:51:01 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sun Aug 13 00:51:59 2017 +0700

----------------------------------------------------------------------
 .../Taxonomy/FloatAssociationFacetField.cs      |   4 +-
 src/Lucene.Net.Misc/Document/LazyDocument.cs    |  36 ++
 .../Index/TestIndexWriterExceptions.cs          |  36 ++
 .../Index/TestIndexableField.cs                 |  36 ++
 src/Lucene.Net/Document/DoubleField.cs          |   4 +-
 src/Lucene.Net/Document/Field.cs                | 198 +++++++--
 src/Lucene.Net/Document/FloatField.cs           |   4 +-
 src/Lucene.Net/Document/IntField.cs             |   4 +-
 src/Lucene.Net/Document/LongField.cs            |   4 +-
 .../Document/NumericDocValuesField.cs           |   2 +-
 src/Lucene.Net/Document/StoredField.cs          |   8 +-
 src/Lucene.Net/Index/IndexableField.cs          |  48 ++-
 src/Lucene.Net/Lucene.Net.csproj                |   1 +
 .../Support/Document/DocumentExtensions.cs      |  17 +
 src/Lucene.Net/Support/Document/Field.cs        | 412 +++++++++++++++++++
 15 files changed, 773 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs b/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs
index 8595a0f..eb54233 100644
--- a/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/FloatAssociationFacetField.cs
@@ -50,7 +50,7 @@ namespace Lucene.Net.Facet.Taxonomy
         /// </summary>
         public static BytesRef SingleToBytesRef(float v)
         {
-            return Int32AssociationFacetField.Int32ToBytesRef(Number.SingleToInt32Bits(v));
+            return Int32AssociationFacetField.Int32ToBytesRef(Support.Number.SingleToInt32Bits(v));
         }
 
         /// <summary>
@@ -60,7 +60,7 @@ namespace Lucene.Net.Facet.Taxonomy
         /// </summary>
         public static float BytesRefToSingle(BytesRef b)
         {
-            return Number.Int32BitsToSingle(Int32AssociationFacetField.BytesRefToInt32(b));
+            return Support.Number.Int32BitsToSingle(Int32AssociationFacetField.BytesRefToInt32(b));
         }
 
         public override string ToString()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net.Misc/Document/LazyDocument.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Misc/Document/LazyDocument.cs b/src/Lucene.Net.Misc/Document/LazyDocument.cs
index 7bab218..33b8b4a 100644
--- a/src/Lucene.Net.Misc/Document/LazyDocument.cs
+++ b/src/Lucene.Net.Misc/Document/LazyDocument.cs
@@ -204,6 +204,42 @@ namespace Lucene.Net.Documents
                 return GetRealValue().GetNumericValue();
             }
 
+            // LUCENENET specific - created overload for Byte, since we have no Number class in .NET
+            public virtual byte? GetByteValue()
+            {
+                return GetRealValue().GetByteValue();
+            }
+
+            // LUCENENET specific - created overload for Short, since we have no Number class in .NET
+            public virtual short? GetInt16Value()
+            {
+                return GetRealValue().GetInt16Value();
+            }
+
+            // LUCENENET specific - created overload for Int32, since we have no Number class in .NET
+            public virtual int? GetInt32Value()
+            {
+                return GetRealValue().GetInt32Value();
+            }
+
+            // LUCENENET specific - created overload for Int64, since we have no Number class in .NET
+            public virtual long? GetInt64Value()
+            {
+                return GetRealValue().GetInt64Value();
+            }
+
+            // LUCENENET specific - created overload for Single, since we have no Number class in .NET
+            public virtual float? GetSingleValue()
+            {
+                return GetRealValue().GetSingleValue();
+            }
+
+            // LUCENENET specific - created overload for Double, since we have no Number class in .NET
+            public virtual double? GetDoubleValue()
+            {
+                return GetRealValue().GetDoubleValue();
+            }
+
             public virtual IIndexableFieldType IndexableFieldType
             {
                 get { return GetRealValue().IndexableFieldType; }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
index feded19..4d557e1 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
@@ -2031,6 +2031,42 @@ namespace Lucene.Net.Index
                 return null;
             }
 
+            // LUCENENET specific - created overload for Byte, since we have no Number class in .NET
+            public virtual byte? GetByteValue()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Short, since we have no Number class in .NET
+            public virtual short? GetInt16Value()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Int32, since we have no Number class in .NET
+            public virtual int? GetInt32Value()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Int64, since we have no Number class in .NET
+            public virtual long? GetInt64Value()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Single, since we have no Number class in .NET
+            public virtual float? GetSingleValue()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Double, since we have no Number class in .NET
+            public virtual double? GetDoubleValue()
+            {
+                return null;
+            }
+
             public TokenStream GetTokenStream(Analyzer analyzer)
             {
                 return null;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net.Tests/Index/TestIndexableField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexableField.cs b/src/Lucene.Net.Tests/Index/TestIndexableField.cs
index b41f9c2..2aac045 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexableField.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexableField.cs
@@ -195,6 +195,42 @@ namespace Lucene.Net.Index
                 return null;
             }
 
+            // LUCENENET specific - created overload for Byte, since we have no Number class in .NET
+            public virtual byte? GetByteValue()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Short, since we have no Number class in .NET
+            public virtual short? GetInt16Value()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Int32, since we have no Number class in .NET
+            public virtual int? GetInt32Value()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Int64, since we have no Number class in .NET
+            public virtual long? GetInt64Value()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Single, since we have no Number class in .NET
+            public virtual float? GetSingleValue()
+            {
+                return null;
+            }
+
+            // LUCENENET specific - created overload for Double, since we have no Number class in .NET
+            public virtual double? GetDoubleValue()
+            {
+                return null;
+            }
+
             public IIndexableFieldType IndexableFieldType
             {
                 get { return fieldType; }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Document/DoubleField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/DoubleField.cs b/src/Lucene.Net/Document/DoubleField.cs
index f764782..16d089d 100644
--- a/src/Lucene.Net/Document/DoubleField.cs
+++ b/src/Lucene.Net/Document/DoubleField.cs
@@ -155,7 +155,7 @@ namespace Lucene.Net.Documents
         public DoubleField(string name, double value, Store stored)
             : base(name, stored == Store.YES ? TYPE_STORED : TYPE_NOT_STORED)
         {
-            m_fieldsData = Convert.ToDouble(value);
+            m_fieldsData = new Double(value);
         }
 
         /// <summary>
@@ -174,7 +174,7 @@ namespace Lucene.Net.Documents
             {
                 throw new System.ArgumentException("type.NumericType must be NumericType.DOUBLE but got " + type.NumericType);
             }
-            m_fieldsData = Convert.ToDouble(value);
+            m_fieldsData = new Double(value);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Document/Field.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/Field.cs b/src/Lucene.Net/Document/Field.cs
index 9c0f6ce..793b047 100644
--- a/src/Lucene.Net/Document/Field.cs
+++ b/src/Lucene.Net/Document/Field.cs
@@ -49,7 +49,7 @@ namespace Lucene.Net.Documents
 #if FEATURE_SERIALIZABLE
     [Serializable]
 #endif
-    public class Field : IIndexableField
+    public partial class Field : IIndexableField
     {
         /// <summary>
         /// Field's type
@@ -290,7 +290,7 @@ namespace Lucene.Net.Documents
         /// </summary>
         public virtual string GetStringValue() // LUCENENET specific: Added verb Get to make it more clear that this returns the value
         {
-            if (m_fieldsData is string || m_fieldsData is int || m_fieldsData is float || m_fieldsData is double || m_fieldsData is long)
+            if (m_fieldsData is string || m_fieldsData is Number)
             {
                 return m_fieldsData.ToString();
             }
@@ -301,6 +301,59 @@ namespace Lucene.Net.Documents
         }
 
         /// <summary>
+        /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+        /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+        /// <see cref="GetBinaryValue()"/> must be set.
+        /// </summary>
+        public virtual string GetStringValue(IFormatProvider provider) // LUCENENET specific: Added verb Get to make it more clear that this returns the value
+        {
+            if (m_fieldsData is string)
+            {
+                return m_fieldsData.ToString();
+            }
+            else if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).ToString(provider);
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        public virtual string GetStringValue(string format) // LUCENENET specific: Added verb Get to make it more clear that this returns the value
+        {
+            if (m_fieldsData is string)
+            {
+                return m_fieldsData.ToString();
+            }
+            else if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).ToString(format);
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        public virtual string GetStringValue(string format, IFormatProvider provider) // LUCENENET specific: Added verb Get to make it more clear that this returns the value
+        {
+            if (m_fieldsData is string)
+            {
+                return m_fieldsData.ToString();
+            }
+            else if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).ToString(format, provider);
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        /// <summary>
         /// The value of the field as a <see cref="TextReader"/>, or <c>null</c>. If <c>null</c>, the <see cref="string"/> value or
         /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
         /// <see cref="GetBinaryValue()"/> must be set.
@@ -392,11 +445,11 @@ namespace Lucene.Net.Documents
         /// </summary>
         public virtual void SetByteValue(byte value)
         {
-            if (!(m_fieldsData is byte?))
+            if (!(m_fieldsData is Byte))
             {
                 throw new System.ArgumentException("cannot change value type from " + m_fieldsData.GetType().Name + " to Byte");
             }
-            m_fieldsData = Convert.ToByte(value);
+            m_fieldsData = new Byte(value);
         }
 
         /// <summary>
@@ -405,11 +458,11 @@ namespace Lucene.Net.Documents
         /// </summary>
         public virtual void SetInt16Value(short value) // LUCENENET specific: Renamed from SetShortValue to follow .NET conventions
         {
-            if (!(m_fieldsData is short?))
+            if (!(m_fieldsData is Int16))
             {
                 throw new System.ArgumentException("cannot change value type from " + m_fieldsData.GetType().Name + " to Short");
             }
-            m_fieldsData = Convert.ToInt16(value);
+            m_fieldsData = new Int16(value);
         }
 
         /// <summary>
@@ -418,11 +471,11 @@ namespace Lucene.Net.Documents
         /// </summary>
         public virtual void SetInt32Value(int value) // LUCENENET specific: Renamed from SetIntValue to follow .NET conventions
         {
-            if (!(m_fieldsData is int?))
+            if (!(m_fieldsData is Int32))
             {
                 throw new System.ArgumentException("cannot change value type from " + m_fieldsData.GetType().Name + " to Integer");
             }
-            m_fieldsData = Convert.ToInt32(value);
+            m_fieldsData = new Int32(value);
         }
 
         /// <summary>
@@ -431,11 +484,11 @@ namespace Lucene.Net.Documents
         /// </summary>
         public virtual void SetInt64Value(long value) // LUCENENET specific: Renamed from SetLongValue to follow .NET conventions
         {
-            if (!(m_fieldsData is long?))
+            if (!(m_fieldsData is Int64))
             {
                 throw new System.ArgumentException("cannot change value type from " + m_fieldsData.GetType().Name + " to Long");
             }
-            m_fieldsData = Convert.ToInt64(value);
+            m_fieldsData = new Int64(value);
         }
 
         /// <summary>
@@ -444,11 +497,11 @@ namespace Lucene.Net.Documents
         /// </summary>
         public virtual void SetSingleValue(float value) // LUCENENET specific: Renamed from SetFloatValue to follow .NET conventions
         {
-            if (!(m_fieldsData is float?))
+            if (!(m_fieldsData is Single))
             {
                 throw new System.ArgumentException("cannot change value type from " + m_fieldsData.GetType().Name + " to Float");
             }
-            m_fieldsData = Convert.ToSingle(value);
+            m_fieldsData = new Single(value);
         }
 
         /// <summary>
@@ -457,11 +510,11 @@ namespace Lucene.Net.Documents
         /// </summary>
         public virtual void SetDoubleValue(double value)
         {
-            if (!(m_fieldsData is double?))
+            if (!(m_fieldsData is Double))
             {
                 throw new System.ArgumentException("cannot change value type from " + m_fieldsData.GetType().Name + " to Double");
             }
-            m_fieldsData = Convert.ToDouble(value);
+            m_fieldsData = new Double(value);
         }
 
         // LUCENENET TODO: Add SetValue() overloads for each type?
@@ -527,14 +580,113 @@ namespace Lucene.Net.Documents
             // wrong StoredFieldsVisitor method will be called (in this case it was calling Int64Field() instead of StringField()).
             // This is an extremely difficult thing to track down and very confusing to end users.
 
-            if (m_fieldsData is int || m_fieldsData is float || m_fieldsData is double || m_fieldsData is long)
+            if (m_fieldsData is Int32)
+            {
+                return ((Int32)m_fieldsData).GetInt32Value();
+            }
+            else if (m_fieldsData is Int64)
+            {
+                return ((Int64)m_fieldsData).GetInt64Value();
+            }
+            else if (m_fieldsData is Single)
+            {
+                return ((Single)m_fieldsData).GetSingleValue();
+            }
+            else if (m_fieldsData is Double)
             {
-                return m_fieldsData;
+                return ((Double)m_fieldsData).GetDoubleValue();
+            }
+            else if (m_fieldsData is Int16)
+            {
+                return ((Int16)m_fieldsData).GetInt16Value();
+            }
+            else if (m_fieldsData is Byte)
+            {
+                return ((Byte)m_fieldsData).GetByteValue();
             }
 
             return null;
         }
 
+        // LUCENENET specific - created overload for Byte, since we have no Number class in .NET
+        public virtual byte? GetByteValue()
+        {
+            if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).GetByteValue();
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        // LUCENENET specific - created overload for Short, since we have no Number class in .NET
+        public virtual short? GetInt16Value()
+        {
+            if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).GetInt16Value();
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        // LUCENENET specific - created overload for Int32, since we have no Number class in .NET
+        public virtual int? GetInt32Value()
+        {
+            if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).GetInt32Value();
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        // LUCENENET specific - created overload for Int64, since we have no Number class in .NET
+        public virtual long? GetInt64Value()
+        {
+            if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).GetInt64Value();
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        // LUCENENET specific - created overload for Single, since we have no Number class in .NET
+        public virtual float? GetSingleValue()
+        {
+            if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).GetSingleValue();
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        // LUCENENET specific - created overload for Double, since we have no Number class in .NET
+        public virtual double? GetDoubleValue()
+        {
+            if (m_fieldsData is Number)
+            {
+                return ((Number)m_fieldsData).GetDoubleValue();
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+
         public virtual BytesRef GetBinaryValue() // LUCENENET specific: Added verb Get to make it more clear that this returns the value
         {
             if (m_fieldsData is BytesRef)
@@ -599,23 +751,23 @@ namespace Lucene.Net.Documents
                 }
                 var nts = (NumericTokenStream)internalTokenStream;
                 // initialize value in TokenStream
-                object val = m_fieldsData;
+                Number val = (Number)m_fieldsData;
                 switch (numericType)
                 {
                     case NumericType.INT32:
-                        nts.SetInt32Value(Convert.ToInt32(val));
+                        nts.SetInt32Value(val.GetInt32Value());
                         break;
 
                     case NumericType.INT64:
-                        nts.SetInt64Value(Convert.ToInt64(val));
+                        nts.SetInt64Value(val.GetInt64Value());
                         break;
 
                     case NumericType.SINGLE:
-                        nts.SetSingleValue(Convert.ToSingle(val));
+                        nts.SetSingleValue(val.GetSingleValue());
                         break;
 
                     case NumericType.DOUBLE:
-                        nts.SetDoubleValue(Convert.ToDouble(val));
+                        nts.SetDoubleValue(val.GetDoubleValue());
                         break;
 
                     default:
@@ -636,7 +788,7 @@ namespace Lucene.Net.Documents
                     // (attributes,...) if not needed (stored field loading)
                     internalTokenStream = new StringTokenStream();
                 }
-                ((StringTokenStream)internalTokenStream).SetValue(GetStringValue());
+                ((StringTokenStream)internalTokenStream).SetValue(GetStringValue()); // LUCENENET TODO: API Make overload that accepts format/provider
                 return internalTokenStream;
             }
 
@@ -650,7 +802,7 @@ namespace Lucene.Net.Documents
             }
             else if (GetStringValue() != null)
             {
-                TextReader sr = new StringReader(GetStringValue());
+                TextReader sr = new StringReader(GetStringValue()); // LUCENENET TODO: API Make overload that accepts format/provider
                 return analyzer.GetTokenStream(Name, sr);
             }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Document/FloatField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/FloatField.cs b/src/Lucene.Net/Document/FloatField.cs
index 51adec3..a602c99 100644
--- a/src/Lucene.Net/Document/FloatField.cs
+++ b/src/Lucene.Net/Document/FloatField.cs
@@ -159,7 +159,7 @@ namespace Lucene.Net.Documents
         public SingleField(string name, float value, Store stored)
             : base(name, stored == Store.YES ? TYPE_STORED : TYPE_NOT_STORED)
         {
-            m_fieldsData = Convert.ToSingle(value);
+            m_fieldsData = new Single(value);
         }
 
         /// <summary>
@@ -178,7 +178,7 @@ namespace Lucene.Net.Documents
             {
                 throw new System.ArgumentException("type.NumericType must be NumericType.SINGLE but got " + type.NumericType);
             }
-            m_fieldsData = Convert.ToSingle(value);
+            m_fieldsData = new Single(value);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Document/IntField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/IntField.cs b/src/Lucene.Net/Document/IntField.cs
index 0bcaea7..2921900 100644
--- a/src/Lucene.Net/Document/IntField.cs
+++ b/src/Lucene.Net/Document/IntField.cs
@@ -158,7 +158,7 @@ namespace Lucene.Net.Documents
         public Int32Field(string name, int value, Store stored)
             : base(name, stored == Store.YES ? TYPE_STORED : TYPE_NOT_STORED)
         {
-            m_fieldsData = Convert.ToInt32(value);
+            m_fieldsData = new Int32(value);
         }
 
         /// <summary>
@@ -179,7 +179,7 @@ namespace Lucene.Net.Documents
             {
                 throw new System.ArgumentException("type.NumericType must be NumericType.INT32 but got " + type.NumericType);
             }
-            m_fieldsData = Convert.ToInt32(value);
+            m_fieldsData = new Int32(value);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Document/LongField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/LongField.cs b/src/Lucene.Net/Document/LongField.cs
index 43108f1..9249486 100644
--- a/src/Lucene.Net/Document/LongField.cs
+++ b/src/Lucene.Net/Document/LongField.cs
@@ -169,7 +169,7 @@ namespace Lucene.Net.Documents
         public Int64Field(string name, long value, Store stored)
             : base(name, stored == Store.YES ? TYPE_STORED : TYPE_NOT_STORED)
         {
-            m_fieldsData = Convert.ToInt64(value);
+            m_fieldsData = new Int64(value);
         }
 
         /// <summary>
@@ -189,7 +189,7 @@ namespace Lucene.Net.Documents
             {
                 throw new System.ArgumentException("type.NumericType must be NumericType.INT64 but got " + type.NumericType);
             }
-            m_fieldsData = Convert.ToInt64(value);
+            m_fieldsData = new Int64(value);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Document/NumericDocValuesField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/NumericDocValuesField.cs b/src/Lucene.Net/Document/NumericDocValuesField.cs
index 02d79ac..7b6eac2 100644
--- a/src/Lucene.Net/Document/NumericDocValuesField.cs
+++ b/src/Lucene.Net/Document/NumericDocValuesField.cs
@@ -55,7 +55,7 @@ namespace Lucene.Net.Documents
         public NumericDocValuesField(string name, long value)
             : base(name, TYPE)
         {
-            m_fieldsData = Convert.ToInt64(value);
+            m_fieldsData = new Int64(value);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Document/StoredField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/StoredField.cs b/src/Lucene.Net/Document/StoredField.cs
index e881336..dd3d8b2 100644
--- a/src/Lucene.Net/Document/StoredField.cs
+++ b/src/Lucene.Net/Document/StoredField.cs
@@ -101,7 +101,7 @@ namespace Lucene.Net.Documents
         public StoredField(string name, int value)
             : base(name, TYPE)
         {
-            m_fieldsData = value;
+            m_fieldsData = new Int32(value);
         }
 
         /// <summary>
@@ -112,7 +112,7 @@ namespace Lucene.Net.Documents
         public StoredField(string name, float value)
             : base(name, TYPE)
         {
-            m_fieldsData = value;
+            m_fieldsData = new Single(value);
         }
 
         /// <summary>
@@ -123,7 +123,7 @@ namespace Lucene.Net.Documents
         public StoredField(string name, long value)
             : base(name, TYPE)
         {
-            m_fieldsData = value;
+            m_fieldsData = new Int64(value);
         }
 
         /// <summary>
@@ -134,7 +134,7 @@ namespace Lucene.Net.Documents
         public StoredField(string name, double value)
             : base(name, TYPE)
         {
-            m_fieldsData = value;
+            m_fieldsData = new Double(value);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Index/IndexableField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/IndexableField.cs b/src/Lucene.Net/Index/IndexableField.cs
index 98b38d7..a04c5e6 100644
--- a/src/Lucene.Net/Index/IndexableField.cs
+++ b/src/Lucene.Net/Index/IndexableField.cs
@@ -73,11 +73,11 @@ namespace Lucene.Net.Index
         float Boost { get; }
 
         /// <summary>
-        /// Non-null if this field has a binary value </summary>
+        /// Non-null if this field has a binary value. </summary>
         BytesRef GetBinaryValue();
 
         /// <summary>
-        /// Non-null if this field has a string value </summary>
+        /// Non-null if this field has a string value. </summary>
         string GetStringValue();
 
         /// <summary>
@@ -85,10 +85,52 @@ namespace Lucene.Net.Index
         TextReader GetReaderValue();
 
         /// <summary>
-        /// Non-null if this field has a numeric value </summary>
+        /// Non-null if this field has a numeric value. </summary>
         object GetNumericValue(); // LUCENENET TODO: Can we eliminate object?
 
         /// <summary>
+        /// Non-null if this field has a numeric value.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        byte? GetByteValue();
+
+        /// <summary>
+        /// Non-null if this field has a numeric value.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        short? GetInt16Value();
+
+        /// <summary>
+        /// Non-null if this field has a numeric value.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        int? GetInt32Value();
+
+        /// <summary>
+        /// Non-null if this field has a numeric value.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        long? GetInt64Value();
+
+        /// <summary>
+        /// Non-null if this field has a numeric value.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        float? GetSingleValue();
+
+        /// <summary>
+        /// Non-null if this field has a numeric value.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        double? GetDoubleValue();
+
+        /// <summary>
         /// Creates the <see cref="TokenStream"/> used for indexing this field.  If appropriate,
         /// implementations should use the given <see cref="Analyzer"/> to create the <see cref="TokenStream"/>s.
         /// </summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj
index aaa3c7b..8ca72e7 100644
--- a/src/Lucene.Net/Lucene.Net.csproj
+++ b/src/Lucene.Net/Lucene.Net.csproj
@@ -396,6 +396,7 @@
     <Compile Include="LucenePackage.cs" />
     <Compile Include="Support\AssemblyUtils.cs" />
     <Compile Include="Support\Document\DocumentExtensions.cs" />
+    <Compile Include="Support\Document\Field.cs" />
     <Compile Include="Support\IO\Compression\LZOCompressor.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Search\AutomatonQuery.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Support/Document/DocumentExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Document/DocumentExtensions.cs b/src/Lucene.Net/Support/Document/DocumentExtensions.cs
index c04dc21..ba83483 100644
--- a/src/Lucene.Net/Support/Document/DocumentExtensions.cs
+++ b/src/Lucene.Net/Support/Document/DocumentExtensions.cs
@@ -3,6 +3,23 @@ using System.Linq;
 
 namespace Lucene.Net.Documents
 {
+    /*
+     * 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>
     /// Extension methods to the <see cref="Document"/> class.
     /// </summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/beb4894f/src/Lucene.Net/Support/Document/Field.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Document/Field.cs b/src/Lucene.Net/Support/Document/Field.cs
new file mode 100644
index 0000000..81da67e
--- /dev/null
+++ b/src/Lucene.Net/Support/Document/Field.cs
@@ -0,0 +1,412 @@
+using System;
+
+namespace Lucene.Net.Documents
+{
+    /*
+     * 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.
+     */
+
+    public partial class Field
+    {
+
+        // LUCENENET NOTE: The following classes were duplicated from Apache Harmony
+        // because nullable types in .NET are not reference types, therefore storing
+        // them in a field type object will require boxing/unboxing.
+
+#if FEATURE_SERIALIZABLE
+        [Serializable]
+#endif
+        protected abstract class Number
+        {
+            /// <summary>
+            /// Returns this object's value as a <see cref="byte"/>. Might involve rounding and/or
+            /// truncating the value, so it fits into a <see cref="byte"/>.
+            /// </summary>
+            /// <returns>the primitive <see cref="byte"/> value of this object.</returns>
+            public virtual byte GetByteValue()
+            {
+                return (byte)GetInt32Value();
+            }
+
+            /// <summary>
+            /// Returns this object's value as a <see cref="double"/>. Might involve rounding.
+            /// </summary>
+            /// <returns>the primitive <see cref="double"/> value of this object.</returns>
+            public abstract double GetDoubleValue();
+
+            /// <summary>
+            /// Returns this object's value as a <see cref="float"/>. Might involve rounding.
+            /// </summary>
+            /// <returns>the primitive <see cref="float"/> value of this object.</returns>
+            public abstract float GetSingleValue();
+
+            /// <summary>
+            /// Returns this object's value as an <see cref="int"/>. Might involve rounding and/or
+            /// truncating the value, so it fits into an <see cref="int"/>.
+            /// </summary>
+            /// <returns>the primitive <see cref="int"/> value of this object.</returns>
+            public abstract int GetInt32Value();
+
+            /// <summary>
+            /// Returns this object's value as a <see cref="long"/>. Might involve rounding and/or
+            /// truncating the value, so it fits into a <see cref="long"/>.
+            /// </summary>
+            /// <returns>the primitive <see cref="long"/> value of this object.</returns>
+            public abstract long GetInt64Value();
+
+            /// <summary>
+            /// Returns this object's value as a <see cref="short"/>. Might involve rounding and/or
+            /// truncating the value, so it fits into a <see cref="short"/>.
+            /// </summary>
+            /// <returns>the primitive <see cref="short"/> value of this object.</returns>
+            public virtual short GetInt16Value()
+            {
+                return (short)GetInt32Value();
+            }
+
+            public abstract override string ToString(); 
+
+            public abstract string ToString(string format);
+
+            public abstract string ToString(IFormatProvider provider);
+
+            public abstract string ToString(string format, IFormatProvider provider);
+        }
+
+        protected sealed class Byte : Number
+        {
+            /// <summary>
+            /// The value which the receiver represents.
+            /// </summary>
+            private readonly byte value;
+
+            public Byte(byte value)
+            {
+                this.value = value;
+            }
+
+            public override double GetDoubleValue()
+            {
+                return value;
+            }
+
+            public override float GetSingleValue()
+            {
+                return value;
+            }
+
+            public override int GetInt32Value()
+            {
+                return value;
+            }
+
+            public override long GetInt64Value()
+            {
+                return value;
+            }
+
+            public override string ToString()
+            {
+                return value.ToString();
+            }
+
+            public override string ToString(string format)
+            {
+                return value.ToString(format);
+            }
+
+            public override string ToString(IFormatProvider provider)
+            {
+                return value.ToString(provider);
+            }
+
+            public override string ToString(string format, IFormatProvider provider)
+            {
+                return value.ToString(format, provider);
+            }
+        }
+
+        protected sealed class Int16 : Number
+        {
+            /// <summary>
+            /// The value which the receiver represents.
+            /// </summary>
+            private readonly short value;
+
+            public Int16(short value)
+            {
+                this.value = value;
+            }
+
+            public override double GetDoubleValue()
+            {
+                return value;
+            }
+
+            public override float GetSingleValue()
+            {
+                return value;
+            }
+
+            public override int GetInt32Value()
+            {
+                return value;
+            }
+
+            public override long GetInt64Value()
+            {
+                return value;
+            }
+
+            public override short GetInt16Value()
+            {
+                return value;
+            }
+
+            public override string ToString()
+            {
+                return value.ToString();
+            }
+
+            public override string ToString(string format)
+            {
+                return value.ToString(format);
+            }
+
+            public override string ToString(IFormatProvider provider)
+            {
+                return value.ToString(provider);
+            }
+
+            public override string ToString(string format, IFormatProvider provider)
+            {
+                return value.ToString(format, provider);
+            }
+        }
+
+        protected sealed class Int32 : Number
+        {
+            /// <summary>
+            /// The value which the receiver represents.
+            /// </summary>
+            private readonly int value;
+
+            public Int32(int value)
+            {
+                this.value = value;
+            }
+
+            public override double GetDoubleValue()
+            {
+                return value;
+            }
+
+            public override float GetSingleValue()
+            {
+                return value;
+            }
+
+            public override int GetInt32Value()
+            {
+                return value;
+            }
+
+            public override long GetInt64Value()
+            {
+                return value;
+            }
+
+            public override string ToString()
+            {
+                return value.ToString();
+            }
+
+            public override string ToString(string format)
+            {
+                return value.ToString(format);
+            }
+
+            public override string ToString(IFormatProvider provider)
+            {
+                return value.ToString(provider);
+            }
+
+            public override string ToString(string format, IFormatProvider provider)
+            {
+                return value.ToString(format, provider);
+            }
+        }
+
+        protected sealed class Int64 : Number
+        {
+            /// <summary>
+            /// The value which the receiver represents.
+            /// </summary>
+            private readonly long value;
+
+            public Int64(long value)
+            {
+                this.value = value;
+            }
+
+            public override double GetDoubleValue()
+            {
+                return value;
+            }
+
+            public override float GetSingleValue()
+            {
+                return value;
+            }
+
+            public override int GetInt32Value()
+            {
+                return (int)value;
+            }
+
+            public override long GetInt64Value()
+            {
+                return value;
+            }
+
+            public override string ToString()
+            {
+                return value.ToString();
+            }
+
+            public override string ToString(string format)
+            {
+                return value.ToString(format);
+            }
+
+            public override string ToString(IFormatProvider provider)
+            {
+                return value.ToString(provider);
+            }
+
+            public override string ToString(string format, IFormatProvider provider)
+            {
+                return value.ToString(format, provider);
+            }
+        }
+
+        protected sealed class Double : Number
+        {
+            /// <summary>
+            /// The value which the receiver represents.
+            /// </summary>
+            private readonly double value;
+
+            public Double(double value)
+            {
+                this.value = value;
+            }
+
+            public override double GetDoubleValue()
+            {
+                return value;
+            }
+
+            public override float GetSingleValue()
+            {
+                return (float)value;
+            }
+
+            public override int GetInt32Value()
+            {
+                return (int)value;
+            }
+
+            public override long GetInt64Value()
+            {
+                return (long)value;
+            }
+
+            public override string ToString()
+            {
+                return value.ToString();
+            }
+
+            public override string ToString(string format)
+            {
+                return value.ToString(format);
+            }
+
+            public override string ToString(IFormatProvider provider)
+            {
+                return value.ToString(provider);
+            }
+
+            public override string ToString(string format, IFormatProvider provider)
+            {
+                return value.ToString(format, provider);
+            }
+        }
+
+        protected sealed class Single : Number
+        {
+            /// <summary>
+            /// The value which the receiver represents.
+            /// </summary>
+            private readonly float value;
+
+            public Single(float value)
+            {
+                this.value = value;
+            }
+
+            public override double GetDoubleValue()
+            {
+                return value;
+            }
+
+            public override float GetSingleValue()
+            {
+                return value;
+            }
+
+            public override int GetInt32Value()
+            {
+                return (int)value;
+            }
+
+            public override long GetInt64Value()
+            {
+                return (long)value;
+            }
+
+            public override string ToString()
+            {
+                return value.ToString();
+            }
+
+            public override string ToString(string format)
+            {
+                return value.ToString(format);
+            }
+
+            public override string ToString(IFormatProvider provider)
+            {
+                return value.ToString(provider);
+            }
+
+            public override string ToString(string format, IFormatProvider provider)
+            {
+                return value.ToString(format, provider);
+            }
+        }
+    }
+}


[2/5] lucenenet git commit: API: Lucene.Net.Index.IIndexableField: Renamed FieldType > IndexableFieldType and added additional FieldType property on Lucene.Net.Documents.Field that returns FieldType rather than IIndexableFieldType so we can avoid casting

Posted by ni...@apache.org.
API: Lucene.Net.Index.IIndexableField: Renamed FieldType > IndexableFieldType and added additional FieldType property on Lucene.Net.Documents.Field that returns FieldType rather than IIndexableFieldType so we can avoid casting.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/361ceb66
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/361ceb66
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/361ceb66

Branch: refs/heads/master
Commit: 361ceb6610dd3975b6afd9ad5cccdf57c4f5409b
Parents: 729ce5b
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sat Aug 12 17:33:03 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sat Aug 12 17:33:03 2017 +0700

----------------------------------------------------------------------
 .../ByTask/Tasks/ReadTokensTask.cs              |  2 +-
 src/Lucene.Net.Facet/FacetsConfig.cs            |  8 +++---
 .../PostingsHighlight/PostingsHighlighter.cs    |  2 +-
 .../VectorHighlight/BaseFragmentsBuilder.cs     |  2 +-
 .../VectorHighlight/FieldTermStack.cs           |  2 +-
 src/Lucene.Net.Misc/Document/LazyDocument.cs    |  4 +--
 .../Analysis/BaseTokenStreamTestCase.cs         |  2 +-
 .../Index/BaseStoredFieldsFormatTestCase.cs     |  4 +--
 src/Lucene.Net.TestFramework/Index/DocHelper.cs | 14 +++++------
 .../Support/ApiScanTestBase.cs                  |  4 +--
 src/Lucene.Net.TestFramework/Util/TestUtil.cs   | 12 ++++-----
 .../ByTask/Feeds/DocMakerTest.cs                | 20 +++++++--------
 .../Index/Memory/MemoryIndexTest.cs             |  2 +-
 src/Lucene.Net.Tests/Document/TestDocument.cs   |  4 +--
 .../Index/TestBagOfPositions.cs                 |  2 +-
 .../Index/TestDocumentWriter.cs                 |  4 +--
 src/Lucene.Net.Tests/Index/TestFieldInfos.cs    |  2 +-
 src/Lucene.Net.Tests/Index/TestFieldsReader.cs  | 20 +++++++--------
 .../Index/TestIndexWriterExceptions.cs          |  6 ++---
 .../Index/TestIndexableField.cs                 |  2 +-
 src/Lucene.Net.Tests/Index/TestSegmentReader.cs |  4 +--
 src/Lucene.Net/Analysis/NumericTokenStream.cs   |  4 +--
 src/Lucene.Net/Codecs/StoredFieldsWriter.cs     |  4 +--
 src/Lucene.Net/Document/Field.cs                | 19 ++++++++++----
 src/Lucene.Net/Index/DocFieldProcessor.cs       |  4 +--
 src/Lucene.Net/Index/DocInverterPerField.cs     |  2 +-
 src/Lucene.Net/Index/DocValuesProcessor.cs      |  2 +-
 .../Index/FreqProxTermsWriterPerField.cs        |  2 +-
 src/Lucene.Net/Index/IndexableField.cs          |  7 +++++-
 src/Lucene.Net/Index/StoredFieldsProcessor.cs   |  2 +-
 .../Index/TermVectorsConsumerPerField.cs        | 26 ++++++++++----------
 31 files changed, 104 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Benchmark/ByTask/Tasks/ReadTokensTask.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Benchmark/ByTask/Tasks/ReadTokensTask.cs b/src/Lucene.Net.Benchmark/ByTask/Tasks/ReadTokensTask.cs
index 1a8125d..d2b6058 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Tasks/ReadTokensTask.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Tasks/ReadTokensTask.cs
@@ -67,7 +67,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Tasks
             int tokenCount = 0;
             foreach (IIndexableField field in fields)
             {
-                if (!field.FieldType.IsTokenized ||
+                if (!field.IndexableFieldType.IsTokenized ||
                     field is Int32Field ||
                     field is Int64Field ||
                     field is SingleField ||

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Facet/FacetsConfig.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/FacetsConfig.cs b/src/Lucene.Net.Facet/FacetsConfig.cs
index f855a84..abbaf4b 100644
--- a/src/Lucene.Net.Facet/FacetsConfig.cs
+++ b/src/Lucene.Net.Facet/FacetsConfig.cs
@@ -292,7 +292,7 @@ namespace Lucene.Net.Facet
 
             foreach (IIndexableField field in doc.Fields)
             {
-                if (field.FieldType == FacetField.TYPE)
+                if (field.IndexableFieldType == FacetField.TYPE)
                 {
                     FacetField facetField = (FacetField)field;
                     FacetsConfig.DimConfig dimConfig = GetDimConfig(facetField.Dim);
@@ -310,7 +310,7 @@ namespace Lucene.Net.Facet
                     fields.Add(facetField);
                 }
 
-                if (field.FieldType == SortedSetDocValuesFacetField.TYPE)
+                if (field.IndexableFieldType == SortedSetDocValuesFacetField.TYPE)
                 {
                     var facetField = (SortedSetDocValuesFacetField)field;
                     FacetsConfig.DimConfig dimConfig = GetDimConfig(facetField.Dim);
@@ -328,7 +328,7 @@ namespace Lucene.Net.Facet
                     fields.Add(facetField);
                 }
 
-                if (field.FieldType == AssociationFacetField.TYPE)
+                if (field.IndexableFieldType == AssociationFacetField.TYPE)
                 {
                     AssociationFacetField facetField = (AssociationFacetField)field;
                     FacetsConfig.DimConfig dimConfig = GetDimConfig(facetField.Dim);
@@ -392,7 +392,7 @@ namespace Lucene.Net.Facet
 
             foreach (IIndexableField field in doc.Fields)
             {
-                IIndexableFieldType ft = field.FieldType;
+                IIndexableFieldType ft = field.IndexableFieldType;
                 if (ft != FacetField.TYPE && ft != SortedSetDocValuesFacetField.TYPE && ft != AssociationFacetField.TYPE)
                 {
                     result.Add(field);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs b/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs
index 85d6925..3219c14 100644
--- a/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs
+++ b/src/Lucene.Net.Highlighter/PostingsHighlight/PostingsHighlighter.cs
@@ -57,7 +57,7 @@ namespace Lucene.Net.Search.PostingsHighlight
     /// Example usage:
     /// <code>
     ///     // configure field with offsets at index time
-    ///     FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
+    ///     IndexableFieldType offsetsType = new IndexableFieldType(TextField.TYPE_STORED);
     ///     offsetsType.IndexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
     ///     Field body = new Field("body", "foobar", offsetsType);
     ///     

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Highlighter/VectorHighlight/BaseFragmentsBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Highlighter/VectorHighlight/BaseFragmentsBuilder.cs b/src/Lucene.Net.Highlighter/VectorHighlight/BaseFragmentsBuilder.cs
index 696cf7d..6f77027 100644
--- a/src/Lucene.Net.Highlighter/VectorHighlight/BaseFragmentsBuilder.cs
+++ b/src/Lucene.Net.Highlighter/VectorHighlight/BaseFragmentsBuilder.cs
@@ -214,7 +214,7 @@ namespace Lucene.Net.Search.VectorHighlight
             }
             int bufferLength = buffer.Length;
             // we added the multi value char to the last buffer, ignore it
-            if (values[index[0] - 1].FieldType.IsTokenized)
+            if (values[index[0] - 1].IndexableFieldType.IsTokenized)
             {
                 bufferLength--;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Highlighter/VectorHighlight/FieldTermStack.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Highlighter/VectorHighlight/FieldTermStack.cs b/src/Lucene.Net.Highlighter/VectorHighlight/FieldTermStack.cs
index ad83dbc..0c5396c 100644
--- a/src/Lucene.Net.Highlighter/VectorHighlight/FieldTermStack.cs
+++ b/src/Lucene.Net.Highlighter/VectorHighlight/FieldTermStack.cs
@@ -44,7 +44,7 @@ namespace Lucene.Net.Search.VectorHighlight
         //  Directory dir = new RAMDirectory();
         //  IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer));
         //  Document doc = new Document();
-        //  FieldType ft = new FieldType(TextField.TYPE_STORED);
+        //  IndexableFieldType ft = new IndexableFieldType(TextField.TYPE_STORED);
         //  ft.setStoreTermVectors(true);
         //  ft.setStoreTermVectorOffsets(true);
         //  ft.setStoreTermVectorPositions(true);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Misc/Document/LazyDocument.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Misc/Document/LazyDocument.cs b/src/Lucene.Net.Misc/Document/LazyDocument.cs
index 6495164..7bab218 100644
--- a/src/Lucene.Net.Misc/Document/LazyDocument.cs
+++ b/src/Lucene.Net.Misc/Document/LazyDocument.cs
@@ -204,9 +204,9 @@ namespace Lucene.Net.Documents
                 return GetRealValue().GetNumericValue();
             }
 
-            public virtual IIndexableFieldType FieldType
+            public virtual IIndexableFieldType IndexableFieldType
             {
-                get { return GetRealValue().FieldType; }
+                get { return GetRealValue().IndexableFieldType; }
             }
 
             public virtual TokenStream GetTokenStream(Analyzer analyzer)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs b/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
index 78cdd7a..0f2c4de 100644
--- a/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
@@ -832,7 +832,7 @@ namespace Lucene.Net.Analysis
                             if (random.Next(7) == 0)
                             {
                                 // pile up a multivalued field
-                                var ft = (FieldType)field.FieldType;
+                                var ft = field.FieldType;
                                 currentField = new Field("dummy", bogus, ft);
                                 doc.Add(currentField);
                             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
index e5515ad..6ba93de 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
@@ -357,8 +357,8 @@ namespace Lucene.Net.Index
             w.AddDocument(doc);
             IndexReader r = w.Reader;
             w.Dispose();
-            Assert.IsFalse(r.Document(0).GetField("field").FieldType.IsIndexed);
-            Assert.IsTrue(r.Document(0).GetField("field2").FieldType.IsIndexed);
+            Assert.IsFalse(r.Document(0).GetField("field").IndexableFieldType.IsIndexed);
+            Assert.IsTrue(r.Document(0).GetField("field2").IndexableFieldType.IsIndexed);
             r.Dispose();
             dir.Dispose();
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.TestFramework/Index/DocHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/DocHelper.cs b/src/Lucene.Net.TestFramework/Index/DocHelper.cs
index afdbb3b..e5b50f5 100644
--- a/src/Lucene.Net.TestFramework/Index/DocHelper.cs
+++ b/src/Lucene.Net.TestFramework/Index/DocHelper.cs
@@ -264,7 +264,7 @@ namespace Lucene.Net.Index
             {
                 IIndexableField f = Fields[i];
                 Add(All, f);
-                if (f.FieldType.IsIndexed)
+                if (f.IndexableFieldType.IsIndexed)
                 {
                     Add(Indexed, f);
                 }
@@ -272,15 +272,15 @@ namespace Lucene.Net.Index
                 {
                     Add(Unindexed, f);
                 }
-                if (f.FieldType.StoreTermVectors)
+                if (f.IndexableFieldType.StoreTermVectors)
                 {
                     Add(Termvector, f);
                 }
-                if (f.FieldType.IsIndexed && !f.FieldType.StoreTermVectors)
+                if (f.IndexableFieldType.IsIndexed && !f.IndexableFieldType.StoreTermVectors)
                 {
                     Add(Notermvector, f);
                 }
-                if (f.FieldType.IsStored)
+                if (f.IndexableFieldType.IsStored)
                 {
                     Add(Stored, f);
                 }
@@ -288,15 +288,15 @@ namespace Lucene.Net.Index
                 {
                     Add(Unstored, f);
                 }
-                if (f.FieldType.IndexOptions == IndexOptions.DOCS_ONLY)
+                if (f.IndexableFieldType.IndexOptions == IndexOptions.DOCS_ONLY)
                 {
                     Add(NoTf, f);
                 }
-                if (f.FieldType.OmitNorms)
+                if (f.IndexableFieldType.OmitNorms)
                 {
                     Add(NoNorms, f);
                 }
-                if (f.FieldType.IndexOptions == IndexOptions.DOCS_ONLY)
+                if (f.IndexableFieldType.IndexOptions == IndexOptions.DOCS_ONLY)
                 {
                     Add(NoTf, f);
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.TestFramework/Support/ApiScanTestBase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Support/ApiScanTestBase.cs b/src/Lucene.Net.TestFramework/Support/ApiScanTestBase.cs
index 8f389cb..5000115 100644
--- a/src/Lucene.Net.TestFramework/Support/ApiScanTestBase.cs
+++ b/src/Lucene.Net.TestFramework/Support/ApiScanTestBase.cs
@@ -1084,8 +1084,8 @@ namespace Lucene.Net.Support
                             }
                         }
                         //else if (member.MemberType == MemberTypes.Field
-                        //    && ((FieldInfo)member).FieldType.IsGenericType
-                        //    && ((FieldInfo)member).FieldType.GetGenericTypeDefinition().IsAssignableFrom(lookFor)
+                        //    && ((FieldInfo)member).IndexableFieldType.IsGenericType
+                        //    && ((FieldInfo)member).IndexableFieldType.GetGenericTypeDefinition().IsAssignableFrom(lookFor)
                         //    && (!publiclyVisibleOnly || (((FieldInfo)member).IsFamily || ((FieldInfo)member).IsFamilyOrAssembly)))
                         //{
                         //    result.Add(string.Concat(t.FullName, ".", member.Name, " (field)"));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.TestFramework/Util/TestUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/TestUtil.cs b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
index bfc73dd..cec067e 100644
--- a/src/Lucene.Net.TestFramework/Util/TestUtil.cs
+++ b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
@@ -1052,7 +1052,7 @@ namespace Lucene.Net.Util
                 Field field1 = (Field)f;
                 Field field2;
                 DocValuesType dvType = field1.FieldType.DocValueType;
-                NumericType numType = ((FieldType)field1.FieldType).NumericType;
+                NumericType numType = field1.FieldType.NumericType;
                 if (dvType != DocValuesType.NONE)
                 {
                     switch (dvType)
@@ -1078,19 +1078,19 @@ namespace Lucene.Net.Util
                     switch (numType)
                     {
                         case NumericType.INT32:
-                            field2 = new Int32Field(field1.Name, (int)field1.GetNumericValue(), (FieldType)field1.FieldType);
+                            field2 = new Int32Field(field1.Name, (int)field1.GetNumericValue(), field1.FieldType);
                             break;
 
                         case NumericType.SINGLE:
-                            field2 = new SingleField(field1.Name, (int)field1.GetNumericValue(), (FieldType)field1.FieldType);
+                            field2 = new SingleField(field1.Name, (int)field1.GetNumericValue(), field1.FieldType);
                             break;
 
                         case NumericType.INT64:
-                            field2 = new Int64Field(field1.Name, (int)field1.GetNumericValue(), (FieldType)field1.FieldType);
+                            field2 = new Int64Field(field1.Name, (int)field1.GetNumericValue(), field1.FieldType);
                             break;
 
                         case NumericType.DOUBLE:
-                            field2 = new DoubleField(field1.Name, (int)field1.GetNumericValue(), (FieldType)field1.FieldType);
+                            field2 = new DoubleField(field1.Name, (int)field1.GetNumericValue(), field1.FieldType);
                             break;
 
                         default:
@@ -1099,7 +1099,7 @@ namespace Lucene.Net.Util
                 }
                 else
                 {
-                    field2 = new Field(field1.Name, field1.GetStringValue(), (FieldType)field1.FieldType);
+                    field2 = new Field(field1.Name, field1.GetStringValue(), field1.FieldType);
                 }
                 doc2.Add(field2);
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/DocMakerTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/DocMakerTest.cs b/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/DocMakerTest.cs
index e919fb1..ce13abe 100644
--- a/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/DocMakerTest.cs
+++ b/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/DocMakerTest.cs
@@ -141,28 +141,28 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
 
             // Don't set anything, use the defaults
             doc = createTestNormsDocument(false, false, false, false);
-            assertTrue(doc.GetField(DocMaker.TITLE_FIELD).FieldType.OmitNorms);
-            assertFalse(doc.GetField(DocMaker.BODY_FIELD).FieldType.OmitNorms);
+            assertTrue(doc.GetField(DocMaker.TITLE_FIELD).IndexableFieldType.OmitNorms);
+            assertFalse(doc.GetField(DocMaker.BODY_FIELD).IndexableFieldType.OmitNorms);
 
             // Set norms to false
             doc = createTestNormsDocument(true, false, false, false);
-            assertTrue(doc.GetField(DocMaker.TITLE_FIELD).FieldType.OmitNorms);
-            assertFalse(doc.GetField(DocMaker.BODY_FIELD).FieldType.OmitNorms);
+            assertTrue(doc.GetField(DocMaker.TITLE_FIELD).IndexableFieldType.OmitNorms);
+            assertFalse(doc.GetField(DocMaker.BODY_FIELD).IndexableFieldType.OmitNorms);
 
             // Set norms to true
             doc = createTestNormsDocument(true, true, false, false);
-            assertFalse(doc.GetField(DocMaker.TITLE_FIELD).FieldType.OmitNorms);
-            assertFalse(doc.GetField(DocMaker.BODY_FIELD).FieldType.OmitNorms);
+            assertFalse(doc.GetField(DocMaker.TITLE_FIELD).IndexableFieldType.OmitNorms);
+            assertFalse(doc.GetField(DocMaker.BODY_FIELD).IndexableFieldType.OmitNorms);
 
             // Set body norms to false
             doc = createTestNormsDocument(false, false, true, false);
-            assertTrue(doc.GetField(DocMaker.TITLE_FIELD).FieldType.OmitNorms);
-            assertTrue(doc.GetField(DocMaker.BODY_FIELD).FieldType.OmitNorms);
+            assertTrue(doc.GetField(DocMaker.TITLE_FIELD).IndexableFieldType.OmitNorms);
+            assertTrue(doc.GetField(DocMaker.BODY_FIELD).IndexableFieldType.OmitNorms);
 
             // Set body norms to true
             doc = createTestNormsDocument(false, false, true, true);
-            assertTrue(doc.GetField(DocMaker.TITLE_FIELD).FieldType.OmitNorms);
-            assertFalse(doc.GetField(DocMaker.BODY_FIELD).FieldType.OmitNorms);
+            assertTrue(doc.GetField(DocMaker.TITLE_FIELD).IndexableFieldType.OmitNorms);
+            assertFalse(doc.GetField(DocMaker.BODY_FIELD).IndexableFieldType.OmitNorms);
         }
 
         [Test]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests.Memory/Index/Memory/MemoryIndexTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Memory/Index/Memory/MemoryIndexTest.cs b/src/Lucene.Net.Tests.Memory/Index/Memory/MemoryIndexTest.cs
index 3eba683..553be5a 100644
--- a/src/Lucene.Net.Tests.Memory/Index/Memory/MemoryIndexTest.cs
+++ b/src/Lucene.Net.Tests.Memory/Index/Memory/MemoryIndexTest.cs
@@ -487,7 +487,7 @@ namespace Lucene.Net.Index.Memory
                 Document doc = new Document();
                 foreach (IIndexableField field in nextDoc.Fields)
                 {
-                    if (field.FieldType.IsIndexed)
+                    if (field.IndexableFieldType.IsIndexed)
                     {
                         doc.Add(field);
                         if (Random().nextInt(3) == 0)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests/Document/TestDocument.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Document/TestDocument.cs b/src/Lucene.Net.Tests/Document/TestDocument.cs
index 2fd16ed..040690d 100644
--- a/src/Lucene.Net.Tests/Document/TestDocument.cs
+++ b/src/Lucene.Net.Tests/Document/TestDocument.cs
@@ -67,8 +67,8 @@ namespace Lucene.Net.Documents
             Assert.AreEqual(2, doc.Fields.Count);
 
             Assert.IsTrue(binaryFld.GetBinaryValue() != null);
-            Assert.IsTrue(binaryFld.FieldType.IsStored);
-            Assert.IsFalse(binaryFld.FieldType.IsIndexed);
+            Assert.IsTrue(binaryFld.IndexableFieldType.IsStored);
+            Assert.IsFalse(binaryFld.IndexableFieldType.IsIndexed);
 
             string binaryTest = doc.GetBinaryValue("binary").Utf8ToString();
             Assert.IsTrue(binaryTest.Equals(BinaryVal));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs b/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs
index 79b96ba..f64a553 100644
--- a/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs
+++ b/src/Lucene.Net.Tests/Index/TestBagOfPositions.cs
@@ -94,7 +94,7 @@ namespace Lucene.Net.Index
             }
 
             Field prototype = NewTextField("field", "", Field.Store.NO);
-            FieldType fieldType = new FieldType((FieldType)prototype.FieldType);
+            FieldType fieldType = new FieldType(prototype.FieldType);
             if (Random().NextBoolean())
             {
                 fieldType.OmitNorms = true;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests/Index/TestDocumentWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestDocumentWriter.cs b/src/Lucene.Net.Tests/Index/TestDocumentWriter.cs
index 0232486..81a27c6 100644
--- a/src/Lucene.Net.Tests/Index/TestDocumentWriter.cs
+++ b/src/Lucene.Net.Tests/Index/TestDocumentWriter.cs
@@ -80,12 +80,12 @@ namespace Lucene.Net.Index
             IIndexableField[] fields = doc.GetFields("textField2");
             Assert.IsTrue(fields != null && fields.Length == 1);
             Assert.IsTrue(fields[0].GetStringValue().Equals(DocHelper.FIELD_2_TEXT));
-            Assert.IsTrue(fields[0].FieldType.StoreTermVectors);
+            Assert.IsTrue(fields[0].IndexableFieldType.StoreTermVectors);
 
             fields = doc.GetFields("textField1");
             Assert.IsTrue(fields != null && fields.Length == 1);
             Assert.IsTrue(fields[0].GetStringValue().Equals(DocHelper.FIELD_1_TEXT));
-            Assert.IsFalse(fields[0].FieldType.StoreTermVectors);
+            Assert.IsFalse(fields[0].IndexableFieldType.StoreTermVectors);
 
             fields = doc.GetFields("keyField");
             Assert.IsTrue(fields != null && fields.Length == 1);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests/Index/TestFieldInfos.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestFieldInfos.cs b/src/Lucene.Net.Tests/Index/TestFieldInfos.cs
index 35f8d8a..45ec4e8 100644
--- a/src/Lucene.Net.Tests/Index/TestFieldInfos.cs
+++ b/src/Lucene.Net.Tests/Index/TestFieldInfos.cs
@@ -49,7 +49,7 @@ namespace Lucene.Net.Index
             FieldInfos.Builder builder = new FieldInfos.Builder();
             foreach (IIndexableField field in TestDoc)
             {
-                builder.AddOrUpdate(field.Name, field.FieldType);
+                builder.AddOrUpdate(field.Name, field.IndexableFieldType);
             }
             FieldInfos fieldInfos = builder.Finish();
             //Since the complement is stored as well in the fields map

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests/Index/TestFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestFieldsReader.cs b/src/Lucene.Net.Tests/Index/TestFieldsReader.cs
index 5f03962..81251fd 100644
--- a/src/Lucene.Net.Tests/Index/TestFieldsReader.cs
+++ b/src/Lucene.Net.Tests/Index/TestFieldsReader.cs
@@ -59,7 +59,7 @@ namespace Lucene.Net.Index
             DocHelper.SetupDoc(TestDoc);
             foreach (IIndexableField field in TestDoc)
             {
-                FieldInfos.AddOrUpdate(field.Name, field.FieldType);
+                FieldInfos.AddOrUpdate(field.Name, field.IndexableFieldType);
             }
             Dir = NewDirectory();
             IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy());
@@ -92,22 +92,22 @@ namespace Lucene.Net.Index
 
             Field field = (Field)doc.GetField(DocHelper.TEXT_FIELD_2_KEY);
             Assert.IsTrue(field != null);
-            Assert.IsTrue(field.FieldType.StoreTermVectors);
+            Assert.IsTrue(field.IndexableFieldType.StoreTermVectors);
 
-            Assert.IsFalse(field.FieldType.OmitNorms);
-            Assert.IsTrue(field.FieldType.IndexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
+            Assert.IsFalse(field.IndexableFieldType.OmitNorms);
+            Assert.IsTrue(field.IndexableFieldType.IndexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
 
             field = (Field)doc.GetField(DocHelper.TEXT_FIELD_3_KEY);
             Assert.IsTrue(field != null);
-            Assert.IsFalse(field.FieldType.StoreTermVectors);
-            Assert.IsTrue(field.FieldType.OmitNorms);
-            Assert.IsTrue(field.FieldType.IndexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
+            Assert.IsFalse(field.IndexableFieldType.StoreTermVectors);
+            Assert.IsTrue(field.IndexableFieldType.OmitNorms);
+            Assert.IsTrue(field.IndexableFieldType.IndexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
 
             field = (Field)doc.GetField(DocHelper.NO_TF_KEY);
             Assert.IsTrue(field != null);
-            Assert.IsFalse(field.FieldType.StoreTermVectors);
-            Assert.IsFalse(field.FieldType.OmitNorms);
-            Assert.IsTrue(field.FieldType.IndexOptions == IndexOptions.DOCS_ONLY);
+            Assert.IsFalse(field.IndexableFieldType.StoreTermVectors);
+            Assert.IsFalse(field.IndexableFieldType.OmitNorms);
+            Assert.IsTrue(field.IndexableFieldType.IndexOptions == IndexOptions.DOCS_ONLY);
 
             DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(DocHelper.TEXT_FIELD_3_KEY);
             reader.Document(0, visitor);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
index 6733d2f..feded19 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
@@ -1629,7 +1629,7 @@ namespace Lucene.Net.Index
                         try
                         {
                             w.AddDocument(doc);
-                            Assert.IsFalse(field.FieldType.StoreTermVectors);
+                            Assert.IsFalse(field.IndexableFieldType.StoreTermVectors);
                         }
                         catch (Exception e)
                         {
@@ -1654,7 +1654,7 @@ namespace Lucene.Net.Index
                         try
                         {
                             w.AddDocument(doc);
-                            Assert.IsFalse(field.FieldType.StoreTermVectors);
+                            Assert.IsFalse(field.IndexableFieldType.StoreTermVectors);
                         }
                         catch (Exception e)
                         {
@@ -2001,7 +2001,7 @@ namespace Lucene.Net.Index
                 get { return "foo"; }
             }
 
-            public IIndexableFieldType FieldType
+            public IIndexableFieldType IndexableFieldType
             {
                 get { return StringField.TYPE_NOT_STORED; }
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests/Index/TestIndexableField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexableField.cs b/src/Lucene.Net.Tests/Index/TestIndexableField.cs
index e7f5856..b41f9c2 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexableField.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexableField.cs
@@ -195,7 +195,7 @@ namespace Lucene.Net.Index
                 return null;
             }
 
-            public IIndexableFieldType FieldType
+            public IIndexableFieldType IndexableFieldType
             {
                 get { return fieldType; }
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net.Tests/Index/TestSegmentReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestSegmentReader.cs b/src/Lucene.Net.Tests/Index/TestSegmentReader.cs
index b98287d..d96376a 100644
--- a/src/Lucene.Net.Tests/Index/TestSegmentReader.cs
+++ b/src/Lucene.Net.Tests/Index/TestSegmentReader.cs
@@ -191,9 +191,9 @@ namespace Lucene.Net.Index
             for (int i = 0; i < DocHelper.Fields.Length; i++)
             {
                 IIndexableField f = DocHelper.Fields[i];
-                if (f.FieldType.IsIndexed)
+                if (f.IndexableFieldType.IsIndexed)
                 {
-                    Assert.AreEqual(reader.GetNormValues(f.Name) != null, !f.FieldType.OmitNorms);
+                    Assert.AreEqual(reader.GetNormValues(f.Name) != null, !f.IndexableFieldType.OmitNorms);
                     Assert.AreEqual(reader.GetNormValues(f.Name) != null, !DocHelper.NoNorms.ContainsKey(f.Name));
                     if (reader.GetNormValues(f.Name) == null)
                     {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Analysis/NumericTokenStream.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Analysis/NumericTokenStream.cs b/src/Lucene.Net/Analysis/NumericTokenStream.cs
index e616ada..c4bf124 100644
--- a/src/Lucene.Net/Analysis/NumericTokenStream.cs
+++ b/src/Lucene.Net/Analysis/NumericTokenStream.cs
@@ -38,7 +38,7 @@ namespace Lucene.Net.Analysis
     /// <para/>Here's an example usage, for an <see cref="int"/> field:
     ///
     /// <code>
-    ///     FieldType fieldType = new FieldType(TextField.TYPE_NOT_STORED)
+    ///     IndexableFieldType fieldType = new IndexableFieldType(TextField.TYPE_NOT_STORED)
     ///     {
     ///         OmitNorms = true,
     ///         IndexOptions = IndexOptions.DOCS_ONLY
@@ -52,7 +52,7 @@ namespace Lucene.Net.Analysis
     ///
     /// <code>
     ///     NumericTokenStream stream = new NumericTokenStream(precisionStep);
-    ///     FieldType fieldType = new FieldType(TextField.TYPE_NOT_STORED)
+    ///     IndexableFieldType fieldType = new IndexableFieldType(TextField.TYPE_NOT_STORED)
     ///     {
     ///         OmitNorms = true,
     ///         IndexOptions = IndexOptions.DOCS_ONLY

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Codecs/StoredFieldsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Codecs/StoredFieldsWriter.cs b/src/Lucene.Net/Codecs/StoredFieldsWriter.cs
index 15f7112..130cfc1 100644
--- a/src/Lucene.Net/Codecs/StoredFieldsWriter.cs
+++ b/src/Lucene.Net/Codecs/StoredFieldsWriter.cs
@@ -135,7 +135,7 @@ namespace Lucene.Net.Codecs
             int storedCount = 0;
             foreach (IIndexableField field in doc)
             {
-                if (field.FieldType.IsStored)
+                if (field.IndexableFieldType.IsStored)
                 {
                     storedCount++;
                 }
@@ -145,7 +145,7 @@ namespace Lucene.Net.Codecs
 
             foreach (IIndexableField field in doc)
             {
-                if (field.FieldType.IsStored)
+                if (field.IndexableFieldType.IsStored)
                 {
                     WriteField(fieldInfos.FieldInfo(field.Name), field);
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Document/Field.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/Field.cs b/src/Lucene.Net/Document/Field.cs
index 8d85c80..9c0f6ce 100644
--- a/src/Lucene.Net/Document/Field.cs
+++ b/src/Lucene.Net/Document/Field.cs
@@ -567,19 +567,28 @@ namespace Lucene.Net.Documents
         }
 
         /// <summary>
-        /// Returns the <see cref="Documents.FieldType"/> for this field. </summary>
-        public virtual IIndexableFieldType FieldType
+        /// Returns the <see cref="Documents.FieldType"/> for this field as type <see cref="Documents.FieldType"/>. </summary>
+        // LUCENENET specific property to prevent the need to cast. The FieldType property was renamed IndexableFieldType
+        // in order to accommodate this (more Lucene like) property.
+        public virtual FieldType FieldType
+        {
+            get { return m_type; }
+        }
+
+        /// <summary>
+        /// Returns the <see cref="Documents.FieldType"/> for this field as type <see cref="IIndexableFieldType"/> </summary>
+        public virtual IIndexableFieldType IndexableFieldType
         {
             get { return m_type; }
         }
 
         public virtual TokenStream GetTokenStream(Analyzer analyzer)
         {
-            if (!((FieldType)FieldType).IsIndexed)
+            if (!FieldType.IsIndexed)
             {
                 return null;
             }
-            NumericType numericType = ((FieldType)FieldType).NumericType;
+            NumericType numericType = FieldType.NumericType;
             if (numericType != NumericType.NONE)
             {
                 if (!(internalTokenStream is NumericTokenStream))
@@ -615,7 +624,7 @@ namespace Lucene.Net.Documents
                 return internalTokenStream;
             }
 
-            if (!((FieldType)FieldType).IsTokenized)
+            if (!IndexableFieldType.IsTokenized)
             {
                 if (GetStringValue() == null)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Index/DocFieldProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/DocFieldProcessor.cs b/src/Lucene.Net/Index/DocFieldProcessor.cs
index b3c288c..e0a412f 100644
--- a/src/Lucene.Net/Index/DocFieldProcessor.cs
+++ b/src/Lucene.Net/Index/DocFieldProcessor.cs
@@ -227,7 +227,7 @@ namespace Lucene.Net.Index
                     // needs to be more "pluggable" such that if I want
                     // to have a new "thing" my Fields can do, I can
                     // easily add it
-                    FieldInfo fi = fieldInfos.AddOrUpdate(fieldName, field.FieldType);
+                    FieldInfo fi = fieldInfos.AddOrUpdate(fieldName, field.IndexableFieldType);
 
                     fp = new DocFieldProcessorPerField(this, fi);
                     fp.next = fieldHash[hashPos];
@@ -243,7 +243,7 @@ namespace Lucene.Net.Index
                 {
                     // need to addOrUpdate so that FieldInfos can update globalFieldNumbers
                     // with the correct DocValue type (LUCENE-5192)
-                    FieldInfo fi = fieldInfos.AddOrUpdate(fieldName, field.FieldType);
+                    FieldInfo fi = fieldInfos.AddOrUpdate(fieldName, field.IndexableFieldType);
                     Debug.Assert(fi == fp.fieldInfo, "should only have updated an existing FieldInfo instance");
                 }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Index/DocInverterPerField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/DocInverterPerField.cs b/src/Lucene.Net/Index/DocInverterPerField.cs
index 9724363..d9bb0c4 100644
--- a/src/Lucene.Net/Index/DocInverterPerField.cs
+++ b/src/Lucene.Net/Index/DocInverterPerField.cs
@@ -72,7 +72,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < count; i++)
             {
                 IIndexableField field = fields[i];
-                IIndexableFieldType fieldType = field.FieldType;
+                IIndexableFieldType fieldType = field.IndexableFieldType;
 
                 // TODO FI: this should be "genericized" to querying
                 // consumer if it wants to see this particular field

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Index/DocValuesProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/DocValuesProcessor.cs b/src/Lucene.Net/Index/DocValuesProcessor.cs
index 6de3f99..0e820f0 100644
--- a/src/Lucene.Net/Index/DocValuesProcessor.cs
+++ b/src/Lucene.Net/Index/DocValuesProcessor.cs
@@ -54,7 +54,7 @@ namespace Lucene.Net.Index
 
         public override void AddField(int docID, IIndexableField field, FieldInfo fieldInfo)
         {
-            DocValuesType dvType = field.FieldType.DocValueType;
+            DocValuesType dvType = field.IndexableFieldType.DocValueType;
             if (dvType != DocValuesType.NONE)
             {
                 fieldInfo.DocValuesType = dvType;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Index/FreqProxTermsWriterPerField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/FreqProxTermsWriterPerField.cs b/src/Lucene.Net/Index/FreqProxTermsWriterPerField.cs
index 8b108ce..07fce0c 100644
--- a/src/Lucene.Net/Index/FreqProxTermsWriterPerField.cs
+++ b/src/Lucene.Net/Index/FreqProxTermsWriterPerField.cs
@@ -125,7 +125,7 @@ namespace Lucene.Net.Index
         {
             for (int i = 0; i < count; i++)
             {
-                if (fields[i].FieldType.IsIndexed)
+                if (fields[i].IndexableFieldType.IsIndexed)
                 {
                     return true;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Index/IndexableField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/IndexableField.cs b/src/Lucene.Net/Index/IndexableField.cs
index 99d09f7..98b38d7 100644
--- a/src/Lucene.Net/Index/IndexableField.cs
+++ b/src/Lucene.Net/Index/IndexableField.cs
@@ -43,7 +43,12 @@ namespace Lucene.Net.Index
         /// <see cref="IIndexableFieldType"/> describing the properties
         /// of this field.
         /// </summary>
-        IIndexableFieldType FieldType { get; }
+        // LUCENENET specific: Renamed from FieldType so we can use that name
+        // on the Field class and return FieldType instead of IIndexableFieldType
+        // to avoid a bunch of casting. In Java, it compiles when you implement this
+        // property with a class that derives from IIndexableFieldType, but in .NET it
+        // does not. 
+        IIndexableFieldType IndexableFieldType { get; }
 
         /// <summary>
         /// Returns the field's index-time boost.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Index/StoredFieldsProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/StoredFieldsProcessor.cs b/src/Lucene.Net/Index/StoredFieldsProcessor.cs
index 53ad45e..ff03302 100644
--- a/src/Lucene.Net/Index/StoredFieldsProcessor.cs
+++ b/src/Lucene.Net/Index/StoredFieldsProcessor.cs
@@ -160,7 +160,7 @@ namespace Lucene.Net.Index
 
         public override void AddField(int docID, IIndexableField field, FieldInfo fieldInfo)
         {
-            if (field.FieldType.IsStored)
+            if (field.IndexableFieldType.IsStored)
             {
                 if (numStoredFields == storedFields.Length)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/361ceb66/src/Lucene.Net/Index/TermVectorsConsumerPerField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/TermVectorsConsumerPerField.cs b/src/Lucene.Net/Index/TermVectorsConsumerPerField.cs
index 16dacea..68a036a 100644
--- a/src/Lucene.Net/Index/TermVectorsConsumerPerField.cs
+++ b/src/Lucene.Net/Index/TermVectorsConsumerPerField.cs
@@ -78,18 +78,18 @@ namespace Lucene.Net.Index
             for (int i = 0; i < count; i++)
             {
                 IIndexableField field = fields[i];
-                if (field.FieldType.IsIndexed)
+                if (field.IndexableFieldType.IsIndexed)
                 {
-                    if (field.FieldType.StoreTermVectors)
+                    if (field.IndexableFieldType.StoreTermVectors)
                     {
                         doVectors = true;
-                        doVectorPositions |= field.FieldType.StoreTermVectorPositions;
-                        doVectorOffsets |= field.FieldType.StoreTermVectorOffsets;
+                        doVectorPositions |= field.IndexableFieldType.StoreTermVectorPositions;
+                        doVectorOffsets |= field.IndexableFieldType.StoreTermVectorOffsets;
                         if (doVectorPositions)
                         {
-                            doVectorPayloads |= field.FieldType.StoreTermVectorPayloads;
+                            doVectorPayloads |= field.IndexableFieldType.StoreTermVectorPayloads;
                         }
-                        else if (field.FieldType.StoreTermVectorPayloads)
+                        else if (field.IndexableFieldType.StoreTermVectorPayloads)
                         {
                             // TODO: move this check somewhere else, and impl the other missing ones
                             throw new System.ArgumentException("cannot index term vector payloads without term vector positions (field=\"" + field.Name + "\")");
@@ -97,15 +97,15 @@ namespace Lucene.Net.Index
                     }
                     else
                     {
-                        if (field.FieldType.StoreTermVectorOffsets)
+                        if (field.IndexableFieldType.StoreTermVectorOffsets)
                         {
                             throw new System.ArgumentException("cannot index term vector offsets when term vectors are not indexed (field=\"" + field.Name + "\")");
                         }
-                        if (field.FieldType.StoreTermVectorPositions)
+                        if (field.IndexableFieldType.StoreTermVectorPositions)
                         {
                             throw new System.ArgumentException("cannot index term vector positions when term vectors are not indexed (field=\"" + field.Name + "\")");
                         }
-                        if (field.FieldType.StoreTermVectorPayloads)
+                        if (field.IndexableFieldType.StoreTermVectorPayloads)
                         {
                             throw new System.ArgumentException("cannot index term vector payloads when term vectors are not indexed (field=\"" + field.Name + "\")");
                         }
@@ -113,19 +113,19 @@ namespace Lucene.Net.Index
                 }
                 else
                 {
-                    if (field.FieldType.StoreTermVectors)
+                    if (field.IndexableFieldType.StoreTermVectors)
                     {
                         throw new System.ArgumentException("cannot index term vectors when field is not indexed (field=\"" + field.Name + "\")");
                     }
-                    if (field.FieldType.StoreTermVectorOffsets)
+                    if (field.IndexableFieldType.StoreTermVectorOffsets)
                     {
                         throw new System.ArgumentException("cannot index term vector offsets when field is not indexed (field=\"" + field.Name + "\")");
                     }
-                    if (field.FieldType.StoreTermVectorPositions)
+                    if (field.IndexableFieldType.StoreTermVectorPositions)
                     {
                         throw new System.ArgumentException("cannot index term vector positions when field is not indexed (field=\"" + field.Name + "\")");
                     }
-                    if (field.FieldType.StoreTermVectorPayloads)
+                    if (field.IndexableFieldType.StoreTermVectorPayloads)
                     {
                         throw new System.ArgumentException("cannot index term vector payloads when field is not indexed (field=\"" + field.Name + "\")");
                     }


[4/5] lucenenet git commit: API: Lucene.Net.Documents.Field: Added GetNumericType() method and refactored codecs, suggest, misc, spatial, and classification so they utilize the GetXXXValue() methods instead of GetNumericValue(). Added extension methods G

Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net/Index/IndexableField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/IndexableField.cs b/src/Lucene.Net/Index/IndexableField.cs
index a04c5e6..7f913ca 100644
--- a/src/Lucene.Net/Index/IndexableField.cs
+++ b/src/Lucene.Net/Index/IndexableField.cs
@@ -1,3 +1,4 @@
+using System;
 using System.IO;
 
 namespace Lucene.Net.Index
@@ -78,56 +79,107 @@ namespace Lucene.Net.Index
 
         /// <summary>
         /// Non-null if this field has a string value. </summary>
+        /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
         string GetStringValue();
 
         /// <summary>
+        /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+        /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+        /// <see cref="GetBinaryValue()"/> must be set.
+        /// </summary>
+        /// <param name="provider">An object that supplies culture-specific formatting information. This parameter has no effect if this field is non-numeric.</param>
+        /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+        // LUCENENET specific overload.
+        string GetStringValue(IFormatProvider provider);
+
+        /// <summary>
+        /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+        /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+        /// <see cref="GetBinaryValue()"/> must be set.
+        /// </summary>
+        /// <param name="format">A standard or custom numeric format string. This parameter has no effect if this field is non-numeric.</param>
+        /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+        // LUCENENET specific overload.
+        string GetStringValue(string format);
+
+        /// <summary>
+        /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+        /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+        /// <see cref="GetBinaryValue()"/> must be set.
+        /// </summary>
+        /// <param name="format">A standard or custom numeric format string. This parameter has no effect if this field is non-numeric.</param>
+        /// <param name="provider">An object that supplies culture-specific formatting information. This parameter has no effect if this field is non-numeric.</param>
+        /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+        // LUCENENET specific overload.
+        string GetStringValue(string format, IFormatProvider provider);
+
+
+        /// <summary>
         /// Non-null if this field has a <see cref="TextReader"/> value </summary>
         TextReader GetReaderValue();
 
         /// <summary>
         /// Non-null if this field has a numeric value. </summary>
-        object GetNumericValue(); // LUCENENET TODO: Can we eliminate object?
+        [Obsolete("In .NET, use of this method will cause boxing/unboxing. Instead, call GetNumericType() to check the underlying type and call the appropriate GetXXXValue() method to retrieve the value.")]
+        object GetNumericValue(); 
 
         /// <summary>
-        /// Non-null if this field has a numeric value.
+        /// Gets the <see cref="Type"/> of the underlying value, or <c>null</c> if the value is not set or non-numeric.
         /// <para/>
-        /// LUCENENET specific
+        /// LUCENENET specific. In Java, the numeric type was determined by checking the type of  
+        /// <see cref="GetNumericValue()"/>. However, since there are no reference number
+        /// types in .NET, using <see cref="GetNumericValue()"/> so will cause boxing/unboxing. It is
+        /// therefore recommended to call this method to check the underlying type and the corresponding 
+        /// <c>Get*Value()</c> method to retrieve the value.
         /// </summary>
+        Type GetNumericType();
+
+        /// <summary>
+        /// Returns the field value as <see cref="byte"/> or <c>null</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
+        // LUCENENET specific
         byte? GetByteValue();
 
         /// <summary>
-        /// Non-null if this field has a numeric value.
-        /// <para/>
-        /// LUCENENET specific
+        /// Returns the field value as <see cref="short"/> or <c>null</c> if the type
+        /// is non-numeric.
         /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
+        // LUCENENET specific
         short? GetInt16Value();
 
         /// <summary>
-        /// Non-null if this field has a numeric value.
-        /// <para/>
-        /// LUCENENET specific
+        /// Returns the field value as <see cref="int"/> or <c>null</c> if the type
+        /// is non-numeric.
         /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
+        // LUCENENET specific
         int? GetInt32Value();
 
         /// <summary>
-        /// Non-null if this field has a numeric value.
-        /// <para/>
-        /// LUCENENET specific
+        /// Returns the field value as <see cref="long"/> or <c>null</c> if the type
+        /// is non-numeric.
         /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
+        // LUCENENET specific
         long? GetInt64Value();
 
         /// <summary>
-        /// Non-null if this field has a numeric value.
-        /// <para/>
-        /// LUCENENET specific
+        /// Returns the field value as <see cref="float"/> or <c>null</c> if the type
+        /// is non-numeric.
         /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
+        // LUCENENET specific
         float? GetSingleValue();
 
         /// <summary>
-        /// Non-null if this field has a numeric value.
-        /// <para/>
-        /// LUCENENET specific
+        /// Returns the field value as <see cref="double"/> or <c>null</c> if the type
+        /// is non-numeric.
         /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
+        // LUCENENET specific
         double? GetDoubleValue();
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj
index 8ca72e7..7234e15 100644
--- a/src/Lucene.Net/Lucene.Net.csproj
+++ b/src/Lucene.Net/Lucene.Net.csproj
@@ -397,6 +397,7 @@
     <Compile Include="Support\AssemblyUtils.cs" />
     <Compile Include="Support\Document\DocumentExtensions.cs" />
     <Compile Include="Support\Document\Field.cs" />
+    <Compile Include="Support\Document\IndexableFieldExtensions.cs" />
     <Compile Include="Support\IO\Compression\LZOCompressor.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Search\AutomatonQuery.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net/Support/Document/IndexableFieldExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Document/IndexableFieldExtensions.cs b/src/Lucene.Net/Support/Document/IndexableFieldExtensions.cs
new file mode 100644
index 0000000..d56634d
--- /dev/null
+++ b/src/Lucene.Net/Support/Document/IndexableFieldExtensions.cs
@@ -0,0 +1,99 @@
+using Lucene.Net.Index;
+
+namespace Lucene.Net.Documents
+{
+    /*
+     * 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>
+    /// Extension methods to the <see cref="IIndexableField"/> interface.
+    /// </summary>
+    public static class IndexableFieldExtensions
+    {
+        /// <summary>
+        /// Returns the field value as <see cref="byte"/> or <c>0</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <param name="field">This <see cref="IIndexableField"/>.</param>
+        /// <returns>The field value or <c>0</c> if the type is non-numeric.</returns>
+        public static byte GetByteValueOrDefault(this IIndexableField field)
+        {
+            if (field == null) return default(byte);
+            return field.GetByteValue().GetValueOrDefault();
+        }
+
+        /// <summary>
+        /// Returns the field value as <see cref="short"/> or <c>0</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <param name="field">This <see cref="IIndexableField"/>.</param>
+        /// <returns>The field value or <c>0</c> if the type is non-numeric.</returns>
+        public static short GetInt16ValueOrDefault(this IIndexableField field)
+        {
+            if (field == null) return default(short);
+            return field.GetInt16Value().GetValueOrDefault();
+        }
+
+        /// <summary>
+        /// Returns the field value as <see cref="int"/> or <c>0</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <param name="field">This <see cref="IIndexableField"/>.</param>
+        /// <returns>The field value or <c>0</c> if the type is non-numeric.</returns>
+        public static int GetInt32ValueOrDefault(this IIndexableField field)
+        {
+            if (field == null) return default(int);
+            return field.GetInt32Value().GetValueOrDefault();
+        }
+
+        /// <summary>
+        /// Returns the field value as <see cref="long"/> or <c>0</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <param name="field">This <see cref="IIndexableField"/>.</param>
+        /// <returns>The field value or <c>0</c> if the type is non-numeric.</returns>
+        public static long GetInt64ValueOrDefault(this IIndexableField field)
+        {
+            if (field == null) return default(long);
+            return field.GetInt64Value().GetValueOrDefault();
+        }
+
+        /// <summary>
+        /// Returns the field value as <see cref="float"/> or <c>0</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <param name="field">This <see cref="IIndexableField"/>.</param>
+        /// <returns>The field value or <c>0</c> if the type is non-numeric.</returns>
+        public static float GetSingleValueOrDefault(this IIndexableField field)
+        {
+            if (field == null) return default(float);
+            return field.GetSingleValue().GetValueOrDefault();
+        }
+
+        /// <summary>
+        /// Returns the field value as <see cref="double"/> or <c>0</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <param name="field">This <see cref="IIndexableField"/>.</param>
+        /// <returns>The field value or <c>0</c> if the type is non-numeric.</returns>
+        public static double GetDoubleValueOrDefault(this IIndexableField field)
+        {
+            if (field == null) return default(double);
+            return field.GetDoubleValue().GetValueOrDefault();
+        }
+    }
+}


[5/5] lucenenet git commit: API: Lucene.Net.Documents.Field: Added GetNumericType() method and refactored codecs, suggest, misc, spatial, and classification so they utilize the GetXXXValue() methods instead of GetNumericValue(). Added extension methods G

Posted by ni...@apache.org.
API: Lucene.Net.Documents.Field: Added GetNumericType() method and refactored codecs, suggest, misc, spatial, and classification so they utilize the GetXXXValue() methods instead of GetNumericValue(). Added extension methods GetXXXValueOrDefault() to easily retrieve the numeric value if it is not a concern that it could be null.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c22ef079
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c22ef079
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c22ef079

Branch: refs/heads/master
Commit: c22ef079bd29faaba88f4ca1293f0fc3c4ec32ba
Parents: beb4894
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sun Aug 13 22:35:30 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sun Aug 13 23:33:02 2017 +0700

----------------------------------------------------------------------
 .../Utils/DatasetSplitter.cs                    |  20 ++-
 .../SimpleText/SimpleTextStoredFieldsWriter.cs  |  30 ++--
 src/Lucene.Net.Misc/Document/LazyDocument.cs    | 115 ++++++++++++++++
 .../Suggest/DocumentDictionary.cs               |   4 +-
 .../Lucene3x/PreFlexRWStoredFieldsWriter.cs     |  33 +++--
 .../Index/BaseStoredFieldsFormatTestCase.cs     |   8 +-
 .../Util/LuceneTestCase.cs                      |   2 +
 src/Lucene.Net.TestFramework/Util/TestUtil.cs   |  10 +-
 .../Highlight/HighlighterTest.cs                |   3 +-
 src/Lucene.Net.Tests.Join/TestBlockJoin.cs      |   2 +-
 src/Lucene.Net.Tests.Spatial/SpatialExample.cs  |   2 +-
 .../Suggest/DocumentDictionaryTest.cs           |   8 +-
 .../DocumentValueSourceDictionaryTest.cs        |  22 +--
 src/Lucene.Net.Tests/Document/TestField.cs      |  22 +--
 .../Index/TestIndexWriterExceptions.cs          |  25 ++++
 .../Index/TestIndexableField.cs                 |  25 ++++
 .../Search/TestLiveFieldValues.cs               |   2 +-
 .../Search/TestNumericRangeQuery32.cs           |  24 ++--
 .../Search/TestNumericRangeQuery64.cs           |  24 ++--
 .../CompressingStoredFieldsWriter.cs            | 137 +++++--------------
 .../Lucene40/Lucene40StoredFieldsWriter.cs      |  33 +++--
 src/Lucene.Net/Document/Field.cs                | 116 ++++++++++++++--
 src/Lucene.Net/Index/DocValuesProcessor.cs      |   8 +-
 src/Lucene.Net/Index/IndexableField.cs          |  88 +++++++++---
 src/Lucene.Net/Lucene.Net.csproj                |   1 +
 .../Document/IndexableFieldExtensions.cs        |  99 ++++++++++++++
 26 files changed, 621 insertions(+), 242 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Classification/Utils/DatasetSplitter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Classification/Utils/DatasetSplitter.cs b/src/Lucene.Net.Classification/Utils/DatasetSplitter.cs
index 96af827..8204225 100644
--- a/src/Lucene.Net.Classification/Utils/DatasetSplitter.cs
+++ b/src/Lucene.Net.Classification/Utils/DatasetSplitter.cs
@@ -1,9 +1,10 @@
-using System;
-using System.IO;
 using Lucene.Net.Analysis;
 using Lucene.Net.Documents;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
+using System;
+using System.Globalization;
+using System.IO;
 using Directory = Lucene.Net.Store.Directory;
 
 namespace Lucene.Net.Classification.Utils
@@ -107,9 +108,20 @@ namespace Lucene.Net.Classification.Utils
                             {
                                 doc.Add(new Field(storableField.Name, storableField.GetStringValue(), ft));
                             }
-                            else if (storableField.GetNumericValue() != null)
+                            else if (storableField.GetDoubleValue() != null) // LUCENENET specific - This will cast any numeric type an check whether there is a value without boxing/unboxing
                             {
-                                doc.Add(new Field(storableField.Name, storableField.GetNumericValue().ToString(), ft));
+                                // LUCENENET specific - need to pass invariant culture here (we are assuming the Field will be stored)
+                                // and we need to round-trip floating point numbers so we don't lose precision. 
+                                Type numericType = storableField.GetNumericType();
+                                if (typeof(float).Equals(numericType) || typeof(double).Equals(numericType))
+                                {
+                                    // LUCENENET: Need to specify the "R" for round-trip: http://stackoverflow.com/a/611564
+                                    doc.Add(new Field(storableField.Name, storableField.GetStringValue("R", CultureInfo.InvariantCulture), ft));
+                                }
+                                else
+                                {
+                                    doc.Add(new Field(storableField.Name, storableField.GetStringValue(CultureInfo.InvariantCulture), ft));
+                                }
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs
index 92d68ce..0676811 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextStoredFieldsWriter.cs
@@ -107,51 +107,53 @@ namespace Lucene.Net.Codecs.SimpleText
 
             Write(TYPE);
 
-            var n = field.GetNumericValue();
-
-            if (n != null)
+            // LUCENENET specific - To avoid boxing/unboxing, we don't
+            // call GetNumericValue(). Instead, we check the field type and then
+            // call the appropriate conversion method. 
+            Type numericType = field.GetNumericType();
+            if (numericType != null)
             {
-                if (n is sbyte? || n is short? || n is int?)
+                if (typeof(byte).Equals(numericType) || typeof(short).Equals(numericType) || typeof(int).Equals(numericType))
                 {
                     Write(TYPE_INT);
                     NewLine();
 
                     Write(VALUE);
-                    Write(((int)n).ToString(CultureInfo.InvariantCulture));
+                    Write(field.GetStringValue(CultureInfo.InvariantCulture));
                     NewLine();
                 }
-                else if (n is long?)
+                else if (typeof(long).Equals(numericType))
                 {
                     Write(TYPE_LONG);
                     NewLine();
 
                     Write(VALUE);
-                    Write(((long)n).ToString(CultureInfo.InvariantCulture));
+                    Write(field.GetStringValue(CultureInfo.InvariantCulture));
                     NewLine();
                 }
-                else if (n is float?)
+                else if (typeof(float).Equals(numericType))
                 {
                     Write(TYPE_FLOAT);
                     NewLine();
 
                     Write(VALUE);
-                    // LUCENENET: Need to specify the "R" for round-trip: http://stackoverflow.com/a/611564/181087
-                    Write(((float)n).ToString("R", CultureInfo.InvariantCulture));
+                    // LUCENENET: Need to specify the "R" for round-trip: http://stackoverflow.com/a/611564
+                    Write(field.GetStringValue("R", CultureInfo.InvariantCulture));
                     NewLine();
                 }
-                else if (n is double?)
+                else if (typeof(double).Equals(numericType))
                 {
                     Write(TYPE_DOUBLE);
                     NewLine();
 
                     Write(VALUE);
-                    // LUCENENET: Need to specify the "R" for round-trip: http://stackoverflow.com/a/611564/181087
-                    Write(((double)n).ToString("R", CultureInfo.InvariantCulture));
+                    // LUCENENET: Need to specify the "R" for round-trip: http://stackoverflow.com/a/611564
+                    Write(field.GetStringValue("R", CultureInfo.InvariantCulture));
                     NewLine();
                 }
                 else
                 {
-                    throw new ArgumentException("cannot store numeric type " + n.GetType());
+                    throw new ArgumentException("cannot store numeric type " + numericType);
                 }
             }
             else

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Misc/Document/LazyDocument.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Misc/Document/LazyDocument.cs b/src/Lucene.Net.Misc/Document/LazyDocument.cs
index 33b8b4a..f961bac 100644
--- a/src/Lucene.Net.Misc/Document/LazyDocument.cs
+++ b/src/Lucene.Net.Misc/Document/LazyDocument.cs
@@ -174,72 +174,187 @@ namespace Lucene.Net.Documents
                 return realValue;
             }
 
+            /// <summary>
+            /// The field's name
+            /// </summary>
             public virtual string Name
             {
                 get { return name; }
             }
 
+            /// <summary>
+            /// Gets the boost factor on this field.
+            /// </summary>
             public virtual float Boost
             {
                 get { return 1.0f; }
             }
 
+            /// <summary>
+            /// Non-null if this field has a binary value. </summary>
             public virtual BytesRef GetBinaryValue()
             {
                 return GetRealValue().GetBinaryValue();
             }
 
+            /// <summary>
+            /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+            /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+            /// <see cref="GetBinaryValue()"/> must be set.
+            /// </summary>
+            /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
             public virtual string GetStringValue()
             {
                 return GetRealValue().GetStringValue();
             }
 
+            /// <summary>
+            /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+            /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+            /// <see cref="GetBinaryValue()"/> must be set.
+            /// </summary>
+            /// <param name="provider">An object that supplies culture-specific formatting information. This parameter has no effect if this field is non-numeric.</param>
+            /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified provider
+            public virtual string GetStringValue(IFormatProvider provider) 
+            {
+                return GetRealValue().GetStringValue(provider);
+            }
+
+            /// <summary>
+            /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+            /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+            /// <see cref="GetBinaryValue()"/> must be set.
+            /// </summary>
+            /// <param name="format">A standard or custom numeric format string. This parameter has no effect if this field is non-numeric.</param>
+            /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified format
+            public virtual string GetStringValue(string format) 
+            {
+                return GetRealValue().GetStringValue(format);
+            }
+
+            /// <summary>
+            /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+            /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+            /// <see cref="GetBinaryValue()"/> must be set.
+            /// </summary>
+            /// <param name="format">A standard or custom numeric format string. This parameter has no effect if this field is non-numeric.</param>
+            /// <param name="provider">An object that supplies culture-specific formatting information. This parameter has no effect if this field is non-numeric.</param>
+            /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified format and provider
+            public virtual string GetStringValue(string format, IFormatProvider provider) 
+            {
+                return GetRealValue().GetStringValue(format, provider);
+            }
+
+            /// <summary>
+            /// The value of the field as a <see cref="TextReader"/>, or <c>null</c>. If <c>null</c>, the <see cref="string"/> value or
+            /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+            /// <see cref="GetBinaryValue()"/> must be set.
+            /// </summary>
             public virtual TextReader GetReaderValue()
             {
                 return GetRealValue().GetReaderValue();
             }
 
+            [Obsolete("In .NET, use of this method will cause boxing/unboxing. Instead, call GetNumericType() to check the underlying type and call the appropriate GetXXXValue() method to retrieve the value.")]
             public virtual object GetNumericValue()
             {
                 return GetRealValue().GetNumericValue();
             }
 
+            /// <summary>
+            /// Gets the <see cref="Type"/> of the underlying value, or <c>null</c> if the value is not set or non-numeric.
+            /// <para/>
+            /// LUCENENET specific. In Java, the numeric type was determined by checking the type of  
+            /// <see cref="GetNumericValue()"/>. However, since there are no reference number
+            /// types in .NET, using <see cref="GetNumericValue()"/> so will cause boxing/unboxing. It is
+            /// therefore recommended to call this method to check the underlying type and the corresponding 
+            /// <c>Get*Value()</c> method to retrieve the value.
+            /// </summary>
+            // LUCENENET specific - Since we have no numeric reference types in .NET, this method was added to check
+            // the numeric type of the inner field without boxing/unboxing.
+            public virtual Type GetNumericType()
+            {
+                return GetRealValue().GetNumericType();
+            }
+
+            /// <summary>
+            /// Returns the field value as <see cref="byte"/> or <c>null</c> if the type
+            /// is non-numeric.
+            /// </summary>
+            /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
             // LUCENENET specific - created overload for Byte, since we have no Number class in .NET
             public virtual byte? GetByteValue()
             {
                 return GetRealValue().GetByteValue();
             }
 
+            /// <summary>
+            /// Returns the field value as <see cref="short"/> or <c>null</c> if the type
+            /// is non-numeric.
+            /// </summary>
+            /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
             // LUCENENET specific - created overload for Short, since we have no Number class in .NET
             public virtual short? GetInt16Value()
             {
                 return GetRealValue().GetInt16Value();
             }
 
+            /// <summary>
+            /// Returns the field value as <see cref="int"/> or <c>null</c> if the type
+            /// is non-numeric.
+            /// </summary>
+            /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
             // LUCENENET specific - created overload for Int32, since we have no Number class in .NET
             public virtual int? GetInt32Value()
             {
                 return GetRealValue().GetInt32Value();
             }
 
+            /// <summary>
+            /// Returns the field value as <see cref="long"/> or <c>null</c> if the type
+            /// is non-numeric.
+            /// </summary>
+            /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
             // LUCENENET specific - created overload for Int64, since we have no Number class in .NET
             public virtual long? GetInt64Value()
             {
                 return GetRealValue().GetInt64Value();
             }
 
+            /// <summary>
+            /// Returns the field value as <see cref="float"/> or <c>null</c> if the type
+            /// is non-numeric.
+            /// </summary>
+            /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
             // LUCENENET specific - created overload for Single, since we have no Number class in .NET
             public virtual float? GetSingleValue()
             {
                 return GetRealValue().GetSingleValue();
             }
 
+            /// <summary>
+            /// Returns the field value as <see cref="double"/> or <c>null</c> if the type
+            /// is non-numeric.
+            /// </summary>
+            /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
             // LUCENENET specific - created overload for Double, since we have no Number class in .NET
             public virtual double? GetDoubleValue()
             {
                 return GetRealValue().GetDoubleValue();
             }
 
+            /// <summary>
+            /// Returns the <see cref="Documents.FieldType"/> for this field as type <see cref="Documents.FieldType"/>. </summary>
+            public virtual FieldType FieldType
+            {
+                get { return GetRealValue().IndexableFieldType as FieldType; }
+            }
+
+            /// <summary>
+            /// Returns the <see cref="Documents.FieldType"/> for this field as type <see cref="IIndexableFieldType"/>. </summary>
             public virtual IIndexableFieldType IndexableFieldType
             {
                 get { return GetRealValue().IndexableFieldType; }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Suggest/Suggest/DocumentDictionary.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Suggest/Suggest/DocumentDictionary.cs b/src/Lucene.Net.Suggest/Suggest/DocumentDictionary.cs
index af9fabe..bc1b5b3 100644
--- a/src/Lucene.Net.Suggest/Suggest/DocumentDictionary.cs
+++ b/src/Lucene.Net.Suggest/Suggest/DocumentDictionary.cs
@@ -230,9 +230,7 @@ namespace Lucene.Net.Search.Suggest
                 IIndexableField weight = doc.GetField(outerInstance.weightField);
                 if (weight != null) // found weight as stored
                 {
-                    // LUCENENET TODO: See if we can make NumericValue into Decimal (which can be converted to any other type of number)
-                    // rather than using object.
-                    return (weight.GetNumericValue() != null) ? Convert.ToInt64(weight.GetNumericValue()) : 0;
+                    return weight.GetInt64ValueOrDefault();
                 } // found weight as NumericDocValue
                 else if (weightValues != null)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWStoredFieldsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWStoredFieldsWriter.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWStoredFieldsWriter.cs
index 22ccdf0..5e37f25 100644
--- a/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWStoredFieldsWriter.cs
+++ b/src/Lucene.Net.TestFramework/Codecs/Lucene3x/PreFlexRWStoredFieldsWriter.cs
@@ -117,28 +117,31 @@ namespace Lucene.Net.Codecs.Lucene3x
             // specific encodings for different fields?  and apps
             // can customize...
 
-            object number = field.GetNumericValue();
-            if (number != null)
+            // LUCENENET specific - To avoid boxing/unboxing, we don't
+            // call GetNumericValue(). Instead, we check the field type and then
+            // call the appropriate conversion method. 
+            Type numericType = field.GetNumericType();
+            if (numericType != null)
             {
-                if (number is sbyte? || number is short? || number is int?)
+                if (typeof(byte).Equals(numericType) || typeof(short).Equals(numericType) || typeof(int).Equals(numericType))
                 {
                     bits |= Lucene3xStoredFieldsReader.FIELD_IS_NUMERIC_INT;
                 }
-                else if (number is long?)
+                else if (typeof(long).Equals(numericType))
                 {
                     bits |= Lucene3xStoredFieldsReader.FIELD_IS_NUMERIC_LONG;
                 }
-                else if (number is float?)
+                else if (typeof(float).Equals(numericType))
                 {
                     bits |= Lucene3xStoredFieldsReader.FIELD_IS_NUMERIC_FLOAT;
                 }
-                else if (number is double?)
+                else if (typeof(double).Equals(numericType))
                 {
                     bits |= Lucene3xStoredFieldsReader.FIELD_IS_NUMERIC_DOUBLE;
                 }
                 else
                 {
-                    throw new System.ArgumentException("cannot store numeric type " + number.GetType());
+                    throw new System.ArgumentException("cannot store numeric type " + numericType);
                 }
                 @string = null;
                 bytes = null;
@@ -174,21 +177,21 @@ namespace Lucene.Net.Codecs.Lucene3x
             }
             else
             {
-                if (number is sbyte? || number is short? || number is int?)
+                if (typeof(byte).Equals(numericType) || typeof(short).Equals(numericType) || typeof(int).Equals(numericType))
                 {
-                    FieldsStream.WriteInt32((int)number);
+                    FieldsStream.WriteInt32(field.GetInt32Value().Value);
                 }
-                else if (number is long?)
+                else if (typeof(long).Equals(numericType))
                 {
-                    FieldsStream.WriteInt64((long)number);
+                    FieldsStream.WriteInt64(field.GetInt64Value().Value);
                 }
-                else if (number is float?)
+                else if (typeof(float).Equals(numericType))
                 {
-                    FieldsStream.WriteInt32(Number.SingleToInt32Bits((float)number));
+                    FieldsStream.WriteInt32(Number.SingleToInt32Bits(field.GetSingleValue().Value));
                 }
-                else if (number is double?)
+                else if (typeof(double).Equals(numericType))
                 {
-                    FieldsStream.WriteInt64(BitConverter.DoubleToInt64Bits((double)number));
+                    FieldsStream.WriteInt64(BitConverter.DoubleToInt64Bits(field.GetDoubleValue().Value));
                 }
                 else
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
index 6ba93de..9cde4c7 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
@@ -335,9 +335,11 @@ namespace Lucene.Net.Index
                 for (int docID = 0; docID < sub.NumDocs; docID++)
                 {
                     Document doc = sub.Document(docID);
-                    Field f = (Field)doc.GetField("nf");
+                    Field f = doc.GetField<Field>("nf");
                     Assert.IsTrue(f is StoredField, "got f=" + f);
+#pragma warning disable 612, 618
                     Assert.AreEqual(answers[ids.Get(docID)], f.GetNumericValue());
+#pragma warning restore 612, 618
                 }
             }
             r.Dispose();
@@ -410,7 +412,9 @@ namespace Lucene.Net.Index
                 }
                 else
                 {
+#pragma warning disable 612, 618
                     Assert.AreEqual(fld.GetNumericValue(), sField.GetNumericValue());
+#pragma warning restore 612, 618
                 }
             }
             reader.Dispose();
@@ -647,7 +651,7 @@ namespace Lucene.Net.Index
                     continue;
                 }
                 ++numDocs;
-                int docId = (int)doc.GetField("id").GetNumericValue();
+                int docId = (int)doc.GetField("id").GetInt32Value();
                 Assert.AreEqual(data[docId].Length + 1, doc.Fields.Count);
                 for (int j = 0; j < data[docId].Length; ++j)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 74f9c8e..2dad203 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -2410,7 +2410,9 @@ namespace Lucene.Net.Util
             Assert.AreEqual(leftField.Name, rightField.Name, info);
             Assert.AreEqual(leftField.GetBinaryValue(), rightField.GetBinaryValue(), info);
             Assert.AreEqual(leftField.GetStringValue(), rightField.GetStringValue(), info);
+#pragma warning disable 612, 618
             Assert.AreEqual(leftField.GetNumericValue(), rightField.GetNumericValue(), info);
+#pragma warning restore 612, 618
             // TODO: should we check the FT at all?
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.TestFramework/Util/TestUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/TestUtil.cs b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
index cec067e..62e2267 100644
--- a/src/Lucene.Net.TestFramework/Util/TestUtil.cs
+++ b/src/Lucene.Net.TestFramework/Util/TestUtil.cs
@@ -1058,7 +1058,7 @@ namespace Lucene.Net.Util
                     switch (dvType)
                     {
                         case DocValuesType.NUMERIC:
-                            field2 = new NumericDocValuesField(field1.Name, (long)field1.GetNumericValue());
+                            field2 = new NumericDocValuesField(field1.Name, field1.GetInt64Value().Value);
                             break;
 
                         case DocValuesType.BINARY:
@@ -1078,19 +1078,19 @@ namespace Lucene.Net.Util
                     switch (numType)
                     {
                         case NumericType.INT32:
-                            field2 = new Int32Field(field1.Name, (int)field1.GetNumericValue(), field1.FieldType);
+                            field2 = new Int32Field(field1.Name, field1.GetInt32Value().Value, field1.FieldType);
                             break;
 
                         case NumericType.SINGLE:
-                            field2 = new SingleField(field1.Name, (int)field1.GetNumericValue(), field1.FieldType);
+                            field2 = new SingleField(field1.Name, field1.GetInt32Value().Value, field1.FieldType);
                             break;
 
                         case NumericType.INT64:
-                            field2 = new Int64Field(field1.Name, (int)field1.GetNumericValue(), field1.FieldType);
+                            field2 = new Int64Field(field1.Name, field1.GetInt32Value().Value, field1.FieldType);
                             break;
 
                         case NumericType.DOUBLE:
-                            field2 = new DoubleField(field1.Name, (int)field1.GetNumericValue(), field1.FieldType);
+                            field2 = new DoubleField(field1.Name, field1.GetInt32Value().Value, field1.FieldType);
                             break;
 
                         default:

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests.Highlighter/Highlight/HighlighterTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Highlighter/Highlight/HighlighterTest.cs b/src/Lucene.Net.Tests.Highlighter/Highlight/HighlighterTest.cs
index c7be3a5..03abf65 100644
--- a/src/Lucene.Net.Tests.Highlighter/Highlight/HighlighterTest.cs
+++ b/src/Lucene.Net.Tests.Highlighter/Highlight/HighlighterTest.cs
@@ -11,6 +11,7 @@ using Lucene.Net.Util.Automaton;
 using NUnit.Framework;
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 using System.IO;
 using System.Text;
 using System.Xml;
@@ -512,7 +513,7 @@ namespace Lucene.Net.Search.Highlight
 
             for (int i = 0; i < hits.TotalHits; i++)
             {
-                String text = searcher.Doc(hits.ScoreDocs[i].Doc).GetField(NUMERIC_FIELD_NAME).GetNumericValue().toString();
+                String text = searcher.Doc(hits.ScoreDocs[i].Doc).GetField(NUMERIC_FIELD_NAME).GetStringValue(CultureInfo.InvariantCulture);
                 TokenStream tokenStream = analyzer.GetTokenStream(FIELD_NAME, text);
 
                 highlighter.TextFragmenter = (new SimpleFragmenter(40));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests.Join/TestBlockJoin.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Join/TestBlockJoin.cs b/src/Lucene.Net.Tests.Join/TestBlockJoin.cs
index c28b350..bcd884b 100644
--- a/src/Lucene.Net.Tests.Join/TestBlockJoin.cs
+++ b/src/Lucene.Net.Tests.Join/TestBlockJoin.cs
@@ -207,7 +207,7 @@ namespace Lucene.Net.Tests.Join
             childDoc = s.Doc(hits.ScoreDocs[0].Doc);
             //System.out.println("CHILD = " + childDoc + " docID=" + hits.ScoreDocs[0].Doc);
             assertEquals("java", childDoc.Get("skill"));
-            assertEquals(2007, childDoc.GetField("year").GetNumericValue());
+            assertEquals(2007, childDoc.GetField("year").GetInt32ValueOrDefault());
             assertEquals("Lisa", GetParentDoc(r, parentsFilter, hits.ScoreDocs[0].Doc).Get("name"));
 
             // Test with filter on child docs:

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests.Spatial/SpatialExample.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Spatial/SpatialExample.cs b/src/Lucene.Net.Tests.Spatial/SpatialExample.cs
index b60525b..c6f7c45 100644
--- a/src/Lucene.Net.Tests.Spatial/SpatialExample.cs
+++ b/src/Lucene.Net.Tests.Spatial/SpatialExample.cs
@@ -190,7 +190,7 @@ namespace Lucene.Net.Spatial
             gotIds = new int[docs.TotalHits];
             for (int i = 0; i < gotIds.Length; i++)
             {
-                gotIds[i] = Convert.ToInt32(indexSearcher.Doc(docs.ScoreDocs[i].Doc).GetField("id").GetNumericValue(), CultureInfo.InvariantCulture);
+                gotIds[i] = indexSearcher.Doc(docs.ScoreDocs[i].Doc).GetField("id").GetInt32Value().Value;
             }
             assertArrayEquals(ids, gotIds);
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests.Suggest/Suggest/DocumentDictionaryTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/DocumentDictionaryTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/DocumentDictionaryTest.cs
index bdab9f8..8e34052 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/DocumentDictionaryTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/DocumentDictionaryTest.cs
@@ -160,7 +160,7 @@ namespace Lucene.Net.Search.Suggest
                 //Document doc = docs.Remove(f.Utf8ToString());
                 assertTrue(f.equals(new BytesRef(doc.Get(FIELD_NAME))));
                 IIndexableField weightField = doc.GetField(WEIGHT_FIELD_NAME);
-                assertEquals(inputIterator.Weight, (weightField != null) ? Convert.ToInt64(weightField.GetNumericValue()) : 0);
+                assertEquals(inputIterator.Weight, (weightField != null) ? weightField.GetInt64ValueOrDefault() : 0);
                 assertTrue(inputIterator.Payload.Equals(doc.GetField(PAYLOAD_FIELD_NAME).GetBinaryValue()));
             }
 
@@ -203,7 +203,7 @@ namespace Lucene.Net.Search.Suggest
                 docs.Remove(field);
                 assertTrue(f.equals(new BytesRef(doc.Get(FIELD_NAME))));
                 IIndexableField weightField = doc.GetField(WEIGHT_FIELD_NAME);
-                assertEquals(inputIterator.Weight, (weightField != null) ? Convert.ToInt64(weightField.GetNumericValue()) : 0);
+                assertEquals(inputIterator.Weight, (weightField != null) ? weightField.GetInt64ValueOrDefault() : 0);
                 assertEquals(inputIterator.Payload, null);
             }
 
@@ -249,7 +249,7 @@ namespace Lucene.Net.Search.Suggest
                 //Document doc = docs.remove(f.utf8ToString());
                 assertTrue(f.equals(new BytesRef(doc.Get(FIELD_NAME))));
                 IIndexableField weightField = doc.GetField(WEIGHT_FIELD_NAME);
-                assertEquals(inputIterator.Weight, (weightField != null) ? Convert.ToInt64(weightField.GetNumericValue()) : 0);
+                assertEquals(inputIterator.Weight, (weightField != null) ? weightField.GetInt64ValueOrDefault() : 0);
                 assertTrue(inputIterator.Payload.equals(doc.GetField(PAYLOAD_FIELD_NAME).GetBinaryValue()));
                 ISet<BytesRef> oriCtxs = new HashSet<BytesRef>();
                 IEnumerable<BytesRef> contextSet = inputIterator.Contexts;
@@ -327,7 +327,7 @@ namespace Lucene.Net.Search.Suggest
                 docs.Remove(field);
                 assertTrue(f.equals(new BytesRef(doc.Get(FIELD_NAME))));
                 IIndexableField weightField = doc.GetField(WEIGHT_FIELD_NAME);
-                assertEquals(inputIterator.Weight, (weightField != null) ? Convert.ToInt64(weightField.GetNumericValue()) : 0);
+                assertEquals(inputIterator.Weight, (weightField != null) ? weightField.GetInt64ValueOrDefault() : 0);
                 assertEquals(inputIterator.Payload, null);
             }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests.Suggest/Suggest/DocumentValueSourceDictionaryTest.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Suggest/Suggest/DocumentValueSourceDictionaryTest.cs b/src/Lucene.Net.Tests.Suggest/Suggest/DocumentValueSourceDictionaryTest.cs
index 654089f..818e9d5 100644
--- a/src/Lucene.Net.Tests.Suggest/Suggest/DocumentValueSourceDictionaryTest.cs
+++ b/src/Lucene.Net.Tests.Suggest/Suggest/DocumentValueSourceDictionaryTest.cs
@@ -117,9 +117,9 @@ namespace Lucene.Net.Search.Suggest
                 Document doc = docs.ContainsKey(field) ? docs[field] : null;
                 docs.Remove(field);
                 //Document doc = docs.remove(f.utf8ToString());
-                long w1 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_1).GetNumericValue());
-                long w2 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_2).GetNumericValue());
-                long w3 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_3).GetNumericValue());
+                long w1 = doc.GetField(WEIGHT_FIELD_NAME_1).GetInt64ValueOrDefault();
+                long w2 = doc.GetField(WEIGHT_FIELD_NAME_2).GetInt64ValueOrDefault();
+                long w3 = doc.GetField(WEIGHT_FIELD_NAME_3).GetInt64ValueOrDefault();
                 assertTrue(f.equals(new BytesRef(doc.Get(FIELD_NAME))));
                 assertEquals(inputIterator.Weight, (w1 + w2 + w3));
                 assertTrue(inputIterator.Payload.equals(doc.GetField(PAYLOAD_FIELD_NAME).GetBinaryValue()));
@@ -154,9 +154,9 @@ namespace Lucene.Net.Search.Suggest
                 string field = f.Utf8ToString();
                 Document doc = docs.ContainsKey(field) ? docs[field] : null;
                 docs.Remove(field);
-                long w1 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_1).GetNumericValue());
-                long w2 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_2).GetNumericValue());
-                long w3 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_3).GetNumericValue());
+                long w1 = doc.GetField(WEIGHT_FIELD_NAME_1).GetInt64ValueOrDefault();
+                long w2 = doc.GetField(WEIGHT_FIELD_NAME_2).GetInt64ValueOrDefault();
+                long w3 = doc.GetField(WEIGHT_FIELD_NAME_3).GetInt64ValueOrDefault();
                 assertTrue(f.equals(new BytesRef(doc.Get(FIELD_NAME))));
                 assertEquals(inputIterator.Weight, (w1 + w2 + w3));
                 assertTrue(inputIterator.Payload.equals(doc.GetField(PAYLOAD_FIELD_NAME).GetBinaryValue()));
@@ -197,9 +197,9 @@ namespace Lucene.Net.Search.Suggest
                 string field = f.Utf8ToString();
                 Document doc = docs.ContainsKey(field) ? docs[field] : null;
                 docs.Remove(field);
-                long w1 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_1).GetNumericValue());
-                long w2 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_2).GetNumericValue());
-                long w3 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_3).GetNumericValue());
+                long w1 = doc.GetField(WEIGHT_FIELD_NAME_1).GetInt64ValueOrDefault();
+                long w2 = doc.GetField(WEIGHT_FIELD_NAME_2).GetInt64ValueOrDefault();
+                long w3 = doc.GetField(WEIGHT_FIELD_NAME_3).GetInt64ValueOrDefault();
                 assertTrue(f.equals(new BytesRef(doc.Get(FIELD_NAME))));
                 assertEquals(inputIterator.Weight, (w1 + w2 + w3));
                 assertEquals(inputIterator.Payload, null);
@@ -262,8 +262,8 @@ namespace Lucene.Net.Search.Suggest
                 string field = f.Utf8ToString();
                 Document doc = docs.ContainsKey(field) ? docs[field] : null;
                 docs.Remove(field);
-                long w1 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_1).GetNumericValue());
-                long w2 = Convert.ToInt64(doc.GetField(WEIGHT_FIELD_NAME_2).GetNumericValue());
+                long w1 = doc.GetField(WEIGHT_FIELD_NAME_1).GetInt64ValueOrDefault();
+                long w2 = doc.GetField(WEIGHT_FIELD_NAME_2).GetInt64ValueOrDefault();
                 assertTrue(f.equals(new BytesRef(doc.Get(FIELD_NAME))));
                 assertEquals(inputIterator.Weight, w2 + w1);
                 assertTrue(inputIterator.Payload.equals(doc.GetField(PAYLOAD_FIELD_NAME).GetBinaryValue()));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests/Document/TestField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Document/TestField.cs b/src/Lucene.Net.Tests/Document/TestField.cs
index f436364..9ee7f30 100644
--- a/src/Lucene.Net.Tests/Document/TestField.cs
+++ b/src/Lucene.Net.Tests/Document/TestField.cs
@@ -52,7 +52,7 @@ namespace Lucene.Net.Documents
                 TrySetStringValue(field);
                 TrySetTokenStreamValue(field);
 
-                Assert.AreEqual(6d, (double)field.GetNumericValue(), 0.0d);
+                Assert.AreEqual(6d, field.GetDoubleValue().Value, 0.0d);
             }
         }
 
@@ -74,7 +74,7 @@ namespace Lucene.Net.Documents
             TrySetStringValue(field);
             TrySetTokenStreamValue(field);
 
-            Assert.AreEqual(6d, BitConverter.Int64BitsToDouble((long)field.GetNumericValue()), 0.0d);
+            Assert.AreEqual(6d, BitConverter.Int64BitsToDouble(field.GetInt64Value().Value), 0.0d);
         }
 
         [Test]
@@ -95,7 +95,7 @@ namespace Lucene.Net.Documents
             TrySetStringValue(field);
             TrySetTokenStreamValue(field);
 
-            Assert.AreEqual(6f, Number.Int32BitsToSingle(Convert.ToInt32(field.GetNumericValue())), 0.0f);
+            Assert.AreEqual(6f, Number.Int32BitsToSingle(field.GetInt32Value().Value), 0.0f);
         }
 
         [Test]
@@ -118,7 +118,7 @@ namespace Lucene.Net.Documents
                 TrySetStringValue(field);
                 TrySetTokenStreamValue(field);
 
-                Assert.AreEqual(6f, (float)field.GetNumericValue(), 0.0f);
+                Assert.AreEqual(6f, field.GetSingleValue().Value, 0.0f);
             }
         }
 
@@ -142,7 +142,7 @@ namespace Lucene.Net.Documents
                 TrySetStringValue(field);
                 TrySetTokenStreamValue(field);
 
-                Assert.AreEqual(6, (int)field.GetNumericValue());
+                Assert.AreEqual(6, field.GetInt32Value().Value);
             }
         }
 
@@ -164,7 +164,7 @@ namespace Lucene.Net.Documents
             TrySetStringValue(field);
             TrySetTokenStreamValue(field);
 
-            Assert.AreEqual(6L, (long)field.GetNumericValue());
+            Assert.AreEqual(6L, field.GetInt64Value().Value);
         }
 
         [Test]
@@ -187,7 +187,7 @@ namespace Lucene.Net.Documents
                 TrySetStringValue(field);
                 TrySetTokenStreamValue(field);
 
-                Assert.AreEqual(6L, (long)field.GetNumericValue());
+                Assert.AreEqual(6L, field.GetInt64Value().Value);
             }
         }
 
@@ -371,7 +371,7 @@ namespace Lucene.Net.Documents
             TrySetStringValue(field);
             TrySetTokenStreamValue(field);
 
-            Assert.AreEqual(5, (int)field.GetNumericValue());
+            Assert.AreEqual(5, field.GetInt32Value());
         }
 
         [Test]
@@ -391,7 +391,7 @@ namespace Lucene.Net.Documents
             TrySetStringValue(field);
             TrySetTokenStreamValue(field);
 
-            Assert.AreEqual(5D, (double)field.GetNumericValue(), 0.0D);
+            Assert.AreEqual(5D, field.GetDoubleValue().Value, 0.0D);
         }
 
         [Test]
@@ -411,7 +411,7 @@ namespace Lucene.Net.Documents
             TrySetStringValue(field);
             TrySetTokenStreamValue(field);
 
-            Assert.AreEqual(5f, (float)field.GetNumericValue(), 0.0f);
+            Assert.AreEqual(5f, field.GetSingleValue().Value, 0.0f);
         }
 
         [Test]
@@ -431,7 +431,7 @@ namespace Lucene.Net.Documents
             TrySetStringValue(field);
             TrySetTokenStreamValue(field);
 
-            Assert.AreEqual(5L, (long)field.GetNumericValue());
+            Assert.AreEqual(5L, field.GetInt64Value().Value);
         }
 
         private void TrySetByteValue(Field f)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
index 4d557e1..71cc38a 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
@@ -2021,6 +2021,24 @@ namespace Lucene.Net.Index
                 return "baz";
             }
 
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified provider
+            public virtual string GetStringValue(IFormatProvider provider)
+            {
+                return GetStringValue();
+            }
+
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified format
+            public virtual string GetStringValue(string format)
+            {
+                return GetStringValue();
+            }
+
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified format and provider
+            public virtual string GetStringValue(string format, IFormatProvider provider)
+            {
+                return GetStringValue();
+            }
+
             public TextReader GetReaderValue()
             {
                 return null;
@@ -2031,6 +2049,13 @@ namespace Lucene.Net.Index
                 return null;
             }
 
+            // LUCENENET specific - Since we have no numeric reference types in .NET, this method was added to check
+            // the numeric type of the inner field without boxing/unboxing.
+            public virtual Type GetNumericType()
+            {
+                return null;
+            }
+
             // LUCENENET specific - created overload for Byte, since we have no Number class in .NET
             public virtual byte? GetByteValue()
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests/Index/TestIndexableField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestIndexableField.cs b/src/Lucene.Net.Tests/Index/TestIndexableField.cs
index 2aac045..4be2e2e 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexableField.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexableField.cs
@@ -178,6 +178,24 @@ namespace Lucene.Net.Index
                 }
             }
 
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified provider
+            public virtual string GetStringValue(IFormatProvider provider)
+            {
+                return GetStringValue();
+            }
+
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified format
+            public virtual string GetStringValue(string format)
+            {
+                return GetStringValue();
+            }
+
+            // LUCENENET specific - created overload so we can format an underlying numeric type using specified format and provider
+            public virtual string GetStringValue(string format, IFormatProvider provider)
+            {
+                return GetStringValue();
+            }
+
             public TextReader GetReaderValue()
             {
                 if (Counter % 10 == 7)
@@ -195,6 +213,13 @@ namespace Lucene.Net.Index
                 return null;
             }
 
+            // LUCENENET specific - Since we have no numeric reference types in .NET, this method was added to check
+            // the numeric type of the inner field without boxing/unboxing.
+            public virtual Type GetNumericType()
+            {
+                return null;
+            }
+
             // LUCENENET specific - created overload for Byte, since we have no Number class in .NET
             public virtual byte? GetByteValue()
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests/Search/TestLiveFieldValues.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Search/TestLiveFieldValues.cs b/src/Lucene.Net.Tests/Search/TestLiveFieldValues.cs
index bdf3ecf..5a5b8c1 100644
--- a/src/Lucene.Net.Tests/Search/TestLiveFieldValues.cs
+++ b/src/Lucene.Net.Tests/Search/TestLiveFieldValues.cs
@@ -124,7 +124,7 @@ namespace Lucene.Net.Search
                 else
                 {
                     Document doc = s.Doc(hits.ScoreDocs[0].Doc);
-                    return (int)doc.GetField("field").GetNumericValue();
+                    return doc.GetField("field").GetInt32Value();
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests/Search/TestNumericRangeQuery32.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Search/TestNumericRangeQuery32.cs b/src/Lucene.Net.Tests/Search/TestNumericRangeQuery32.cs
index 6d73ab5..ebf23f2 100644
--- a/src/Lucene.Net.Tests/Search/TestNumericRangeQuery32.cs
+++ b/src/Lucene.Net.Tests/Search/TestNumericRangeQuery32.cs
@@ -195,9 +195,9 @@ namespace Lucene.Net.Search
                 Assert.IsNotNull(sd);
                 Assert.AreEqual(count, sd.Length, "Score doc count" + type);
                 Document doc = Searcher.Doc(sd[0].Doc);
-                Assert.AreEqual(2 * Distance + StartOffset, (int)doc.GetField(field).GetNumericValue(), "First doc" + type);
+                Assert.AreEqual(2 * Distance + StartOffset, doc.GetField(field).GetInt32Value().Value, "First doc" + type);
                 doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-                Assert.AreEqual((1 + count) * Distance + StartOffset, (int)doc.GetField(field).GetNumericValue(), "Last doc" + type);
+                Assert.AreEqual((1 + count) * Distance + StartOffset, doc.GetField(field).GetInt32Value().Value, "Last doc" + type);
             }
         }
 
@@ -252,9 +252,9 @@ namespace Lucene.Net.Search
             Assert.IsNotNull(sd);
             Assert.AreEqual(count, sd.Length, "Score doc count");
             Document doc = Searcher.Doc(sd[0].Doc);
-            Assert.AreEqual(StartOffset, (int)doc.GetField(field).GetNumericValue(), "First doc");
+            Assert.AreEqual(StartOffset, doc.GetField(field).GetInt32Value().Value, "First doc");
             doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-            Assert.AreEqual((count - 1) * Distance + StartOffset, (int)doc.GetField(field).GetNumericValue(), "Last doc");
+            Assert.AreEqual((count - 1) * Distance + StartOffset, doc.GetField(field).GetInt32Value().Value, "Last doc");
 
             q = NumericRangeQuery.NewInt32Range(field, precisionStep, null, upper, false, true);
             topDocs = Searcher.Search(q, null, NoDocs, Sort.INDEXORDER);
@@ -262,9 +262,9 @@ namespace Lucene.Net.Search
             Assert.IsNotNull(sd);
             Assert.AreEqual(count, sd.Length, "Score doc count");
             doc = Searcher.Doc(sd[0].Doc);
-            Assert.AreEqual(StartOffset, (int)doc.GetField(field).GetNumericValue(), "First doc");
+            Assert.AreEqual(StartOffset, doc.GetField(field).GetInt32Value().Value, "First doc");
             doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-            Assert.AreEqual((count - 1) * Distance + StartOffset, (int)doc.GetField(field).GetNumericValue(), "Last doc");
+            Assert.AreEqual((count - 1) * Distance + StartOffset, doc.GetField(field).GetInt32Value().Value, "Last doc");
         }
 
         [Test]
@@ -296,9 +296,9 @@ namespace Lucene.Net.Search
             Assert.IsNotNull(sd);
             Assert.AreEqual(NoDocs - count, sd.Length, "Score doc count");
             Document doc = Searcher.Doc(sd[0].Doc);
-            Assert.AreEqual(count * Distance + StartOffset, (int)doc.GetField(field).GetNumericValue(), "First doc");
+            Assert.AreEqual(count * Distance + StartOffset, doc.GetField(field).GetInt32Value().Value, "First doc");
             doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-            Assert.AreEqual((NoDocs - 1) * Distance + StartOffset, (int)doc.GetField(field).GetNumericValue(), "Last doc");
+            Assert.AreEqual((NoDocs - 1) * Distance + StartOffset, doc.GetField(field).GetInt32Value().Value, "Last doc");
 
             q = NumericRangeQuery.NewInt32Range(field, precisionStep, lower, null, true, false);
             topDocs = Searcher.Search(q, null, NoDocs, Sort.INDEXORDER);
@@ -306,9 +306,9 @@ namespace Lucene.Net.Search
             Assert.IsNotNull(sd);
             Assert.AreEqual(NoDocs - count, sd.Length, "Score doc count");
             doc = Searcher.Doc(sd[0].Doc);
-            Assert.AreEqual(count * Distance + StartOffset, (int)doc.GetField(field).GetNumericValue(), "First doc");
+            Assert.AreEqual(count * Distance + StartOffset, doc.GetField(field).GetInt32Value().Value, "First doc");
             doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-            Assert.AreEqual((NoDocs - 1) * Distance + StartOffset, (int)doc.GetField(field).GetNumericValue(), "Last doc");
+            Assert.AreEqual((NoDocs - 1) * Distance + StartOffset, doc.GetField(field).GetInt32Value().Value, "Last doc");
         }
 
         [Test]
@@ -654,10 +654,10 @@ namespace Lucene.Net.Search
                 }
                 ScoreDoc[] sd = topDocs.ScoreDocs;
                 Assert.IsNotNull(sd);
-                int last = (int)Searcher.Doc(sd[0].Doc).GetField(field).GetNumericValue();
+                int last = Searcher.Doc(sd[0].Doc).GetField(field).GetInt32Value().Value;
                 for (int j = 1; j < sd.Length; j++)
                 {
-                    int act = (int)Searcher.Doc(sd[j].Doc).GetField(field).GetNumericValue();
+                    int act = Searcher.Doc(sd[j].Doc).GetField(field).GetInt32Value().Value;
                     Assert.IsTrue(last > act, "Docs should be sorted backwards");
                     last = act;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net.Tests/Search/TestNumericRangeQuery64.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Search/TestNumericRangeQuery64.cs b/src/Lucene.Net.Tests/Search/TestNumericRangeQuery64.cs
index f26f35c..aeed164 100644
--- a/src/Lucene.Net.Tests/Search/TestNumericRangeQuery64.cs
+++ b/src/Lucene.Net.Tests/Search/TestNumericRangeQuery64.cs
@@ -205,9 +205,9 @@ namespace Lucene.Net.Search
                 Assert.IsNotNull(sd);
                 Assert.AreEqual(count, sd.Length, "Score doc count" + type);
                 Document doc = Searcher.Doc(sd[0].Doc);
-                Assert.AreEqual(2 * Distance + StartOffset, (long)doc.GetField(field).GetNumericValue(), "First doc" + type);
+                Assert.AreEqual(2 * Distance + StartOffset, doc.GetField(field).GetInt64Value().Value, "First doc" + type);
                 doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-                Assert.AreEqual((1 + count) * Distance + StartOffset, (long)doc.GetField(field).GetNumericValue(), "Last doc" + type);
+                Assert.AreEqual((1 + count) * Distance + StartOffset, doc.GetField(field).GetInt64Value().Value, "Last doc" + type);
             }
         }
 
@@ -268,9 +268,9 @@ namespace Lucene.Net.Search
             Assert.IsNotNull(sd);
             Assert.AreEqual(count, sd.Length, "Score doc count");
             Document doc = Searcher.Doc(sd[0].Doc);
-            Assert.AreEqual(StartOffset, (long)doc.GetField(field).GetNumericValue(), "First doc");
+            Assert.AreEqual(StartOffset, doc.GetField(field).GetInt64Value().Value, "First doc");
             doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-            Assert.AreEqual((count - 1) * Distance + StartOffset, (long)doc.GetField(field).GetNumericValue(), "Last doc");
+            Assert.AreEqual((count - 1) * Distance + StartOffset, doc.GetField(field).GetInt64Value().Value, "Last doc");
 
             q = NumericRangeQuery.NewInt64Range(field, precisionStep, null, upper, false, true);
             topDocs = Searcher.Search(q, null, NoDocs, Sort.INDEXORDER);
@@ -278,9 +278,9 @@ namespace Lucene.Net.Search
             Assert.IsNotNull(sd);
             Assert.AreEqual(count, sd.Length, "Score doc count");
             doc = Searcher.Doc(sd[0].Doc);
-            Assert.AreEqual(StartOffset, (long)doc.GetField(field).GetNumericValue(), "First doc");
+            Assert.AreEqual(StartOffset, doc.GetField(field).GetInt64Value().Value, "First doc");
             doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-            Assert.AreEqual((count - 1) * Distance + StartOffset, (long)doc.GetField(field).GetNumericValue(), "Last doc");
+            Assert.AreEqual((count - 1) * Distance + StartOffset, doc.GetField(field).GetInt64Value().Value, "Last doc");
         }
 
         [Test]
@@ -318,9 +318,9 @@ namespace Lucene.Net.Search
             Assert.IsNotNull(sd);
             Assert.AreEqual(NoDocs - count, sd.Length, "Score doc count");
             Document doc = Searcher.Doc(sd[0].Doc);
-            Assert.AreEqual(count * Distance + StartOffset, (long)doc.GetField(field).GetNumericValue(), "First doc");
+            Assert.AreEqual(count * Distance + StartOffset, doc.GetField(field).GetInt64Value().Value, "First doc");
             doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-            Assert.AreEqual((NoDocs - 1) * Distance + StartOffset, (long)doc.GetField(field).GetNumericValue(), "Last doc");
+            Assert.AreEqual((NoDocs - 1) * Distance + StartOffset, doc.GetField(field).GetInt64Value().Value, "Last doc");
 
             q = NumericRangeQuery.NewInt64Range(field, precisionStep, lower, null, true, false);
             topDocs = Searcher.Search(q, null, NoDocs, Sort.INDEXORDER);
@@ -328,9 +328,9 @@ namespace Lucene.Net.Search
             Assert.IsNotNull(sd);
             Assert.AreEqual(NoDocs - count, sd.Length, "Score doc count");
             doc = Searcher.Doc(sd[0].Doc);
-            Assert.AreEqual(count * Distance + StartOffset, (long)doc.GetField(field).GetNumericValue(), "First doc");
+            Assert.AreEqual(count * Distance + StartOffset, doc.GetField(field).GetInt64Value().Value, "First doc");
             doc = Searcher.Doc(sd[sd.Length - 1].Doc);
-            Assert.AreEqual((NoDocs - 1) * Distance + StartOffset, (long)doc.GetField(field).GetNumericValue(), "Last doc");
+            Assert.AreEqual((NoDocs - 1) * Distance + StartOffset, doc.GetField(field).GetInt64Value().Value, "Last doc");
         }
 
         [Test]
@@ -700,10 +700,10 @@ namespace Lucene.Net.Search
                 }
                 ScoreDoc[] sd = topDocs.ScoreDocs;
                 Assert.IsNotNull(sd);
-                long last = (long)Searcher.Doc(sd[0].Doc).GetField(field).GetNumericValue();
+                long last = Searcher.Doc(sd[0].Doc).GetField(field).GetInt64Value().Value;
                 for (int j = 1; j < sd.Length; j++)
                 {
-                    long act = (long)Searcher.Doc(sd[j].Doc).GetField(field).GetNumericValue();
+                    long act = Searcher.Doc(sd[j].Doc).GetField(field).GetInt64Value().Value;
                     Assert.IsTrue(last > act, "Docs should be sorted backwards");
                     last = act;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net/Codecs/Compressing/CompressingStoredFieldsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Codecs/Compressing/CompressingStoredFieldsWriter.cs b/src/Lucene.Net/Codecs/Compressing/CompressingStoredFieldsWriter.cs
index 879bb7a..6703e33 100644
--- a/src/Lucene.Net/Codecs/Compressing/CompressingStoredFieldsWriter.cs
+++ b/src/Lucene.Net/Codecs/Compressing/CompressingStoredFieldsWriter.cs
@@ -6,6 +6,7 @@ using Lucene.Net.Util;
 using Lucene.Net.Util.Packed;
 using System;
 using System.Diagnostics;
+using System.Globalization;
 using Document = Lucene.Net.Documents.Document;
 
 namespace Lucene.Net.Codecs.Compressing
@@ -269,61 +270,31 @@ namespace Lucene.Net.Codecs.Compressing
             BytesRef bytes;
             string @string;
 
-            object number = (object)field.GetNumericValue();
-            if (number != null)
+            // LUCENENET specific - To avoid boxing/unboxing, we don't
+            // call GetNumericValue(). Instead, we check the field type and then
+            // call the appropriate conversion method. 
+            Type numericType = field.GetNumericType();
+            if (numericType != null)
             {
-                if (number is string)
+                if (typeof(byte).Equals(numericType) || typeof(short).Equals(numericType) || typeof(int).Equals(numericType))
                 {
-                    string numStr = number.ToString();
-                    sbyte dummySbyte;
-                    short dummyShort;
-                    int dummyInt;
-                    long dummyLong;
-                    float dummyFloat;
-                    double dummyDouble;
-                    if (sbyte.TryParse(numStr, out dummySbyte) || short.TryParse(numStr, out dummyShort) || int.TryParse(numStr, out dummyInt))
-                    {
-                        bits = NUMERIC_INT32;
-                    }
-                    else if (long.TryParse(numStr, out dummyLong))
-                    {
-                        bits = NUMERIC_INT64;
-                    }
-                    else if (float.TryParse(numStr, out dummyFloat))
-                    {
-                        bits = NUMERIC_SINGLE;
-                    }
-                    else if (double.TryParse(numStr, out dummyDouble))
-                    {
-                        bits = NUMERIC_DOUBLE;
-                    }
-                    else
-                    {
-                        throw new System.ArgumentException("cannot store numeric type " + number.GetType());
-                    }
+                    bits = NUMERIC_INT32;
+                }
+                else if (typeof(long).Equals(numericType))
+                {
+                    bits = NUMERIC_INT64;
+                }
+                else if (typeof(float).Equals(numericType))
+                {
+                    bits = NUMERIC_SINGLE;
+                }
+                else if (typeof(double).Equals(numericType))
+                {
+                    bits = NUMERIC_DOUBLE;
                 }
                 else
                 {
-                    if (number is sbyte || number is short || number is int)
-                    {
-                        bits = NUMERIC_INT32;
-                    }
-                    else if (number is long)
-                    {
-                        bits = NUMERIC_INT64;
-                    }
-                    else if (number is float)
-                    {
-                        bits = NUMERIC_SINGLE;
-                    }
-                    else if (number is double)
-                    {
-                        bits = NUMERIC_DOUBLE;
-                    }
-                    else
-                    {
-                        throw new System.ArgumentException("cannot store numeric type " + number.GetType());
-                    }
+                    throw new System.ArgumentException("cannot store numeric type " + numericType);
                 }
 
                 @string = null;
@@ -343,7 +314,7 @@ namespace Lucene.Net.Codecs.Compressing
                     @string = field.GetStringValue();
                     if (@string == null)
                     {
-                        throw new System.ArgumentException("field " + field.Name + " is stored but does not have binaryValue, stringValue nor numericValue");
+                        throw new System.ArgumentException("field " + field.Name + " is stored but does not have BinaryValue, StringValue nor NumericValue");
                     }
                 }
             }
@@ -362,59 +333,25 @@ namespace Lucene.Net.Codecs.Compressing
             }
             else
             {
-                if (number is string)
+                if (typeof(byte).Equals(numericType) || typeof(short).Equals(numericType) || typeof(int).Equals(numericType))
                 {
-                    string numStr = number.ToString();
-                    sbyte dummySbyte;
-                    short dummyShort;
-                    int dummyInt;
-                    long dummyLong;
-                    float dummyFloat;
-                    double dummyDouble;
-                    if (sbyte.TryParse(numStr, out dummySbyte) || short.TryParse(numStr, out dummyShort) ||
-                        int.TryParse(numStr, out dummyInt))
-                    {
-                        bits = NUMERIC_INT32;
-                    }
-                    else if (long.TryParse(numStr, out dummyLong))
-                    {
-                        bits = NUMERIC_INT64;
-                    }
-                    else if (float.TryParse(numStr, out dummyFloat))
-                    {
-                        bits = NUMERIC_SINGLE;
-                    }
-                    else if (double.TryParse(numStr, out dummyDouble))
-                    {
-                        bits = NUMERIC_DOUBLE;
-                    }
-                    else
-                    {
-                        throw new System.ArgumentException("cannot store numeric type " + number.GetType());
-                    }
+                    bufferedDocs.WriteInt32(field.GetInt32Value().Value);
+                }
+                else if (typeof(long).Equals(numericType))
+                {
+                    bufferedDocs.WriteInt64(field.GetInt64Value().Value);
+                }
+                else if (typeof(float).Equals(numericType))
+                {
+                    bufferedDocs.WriteInt32(Number.SingleToInt32Bits(field.GetSingleValue().Value));
+                }
+                else if (typeof(double).Equals(numericType))
+                {
+                    bufferedDocs.WriteInt64(BitConverter.DoubleToInt64Bits(field.GetDoubleValue().Value));
                 }
                 else
                 {
-                    if (number is sbyte || number is short || number is int)
-                    {
-                        bufferedDocs.WriteInt32((int)number);
-                    }
-                    else if (number is long)
-                    {
-                        bufferedDocs.WriteInt64((long)number);
-                    }
-                    else if (number is float)
-                    {
-                        bufferedDocs.WriteInt32(Number.SingleToInt32Bits((float)number));
-                    }
-                    else if (number is double)
-                    {
-                        bufferedDocs.WriteInt64(BitConverter.DoubleToInt64Bits((double)number));
-                    }
-                    else
-                    {
-                        throw new Exception("Cannot get here");
-                    }
+                    throw new Exception("Cannot get here");
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net/Codecs/Lucene40/Lucene40StoredFieldsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Codecs/Lucene40/Lucene40StoredFieldsWriter.cs b/src/Lucene.Net/Codecs/Lucene40/Lucene40StoredFieldsWriter.cs
index 44b680c..92a6e5f 100644
--- a/src/Lucene.Net/Codecs/Lucene40/Lucene40StoredFieldsWriter.cs
+++ b/src/Lucene.Net/Codecs/Lucene40/Lucene40StoredFieldsWriter.cs
@@ -161,28 +161,31 @@ namespace Lucene.Net.Codecs.Lucene40
             // specific encodings for different fields?  and apps
             // can customize...
 
-            object number = (object)field.GetNumericValue();
-            if (number != null)
+            // LUCENENET specific - To avoid boxing/unboxing, we don't
+            // call GetNumericValue(). Instead, we check the field type and then
+            // call the appropriate conversion method. 
+            Type numericType = field.GetNumericType();
+            if (numericType != null)
             {
-                if (number is sbyte || number is short || number is int)
+                if (typeof(byte).Equals(numericType) || typeof(short).Equals(numericType) || typeof(int).Equals(numericType))
                 {
                     bits |= FIELD_IS_NUMERIC_INT;
                 }
-                else if (number is long)
+                else if (typeof(long).Equals(numericType))
                 {
                     bits |= FIELD_IS_NUMERIC_LONG;
                 }
-                else if (number is float)
+                else if (typeof(float).Equals(numericType))
                 {
                     bits |= FIELD_IS_NUMERIC_FLOAT;
                 }
-                else if (number is double)
+                else if (typeof(double).Equals(numericType))
                 {
                     bits |= FIELD_IS_NUMERIC_DOUBLE;
                 }
                 else
                 {
-                    throw new System.ArgumentException("cannot store numeric type " + number.GetType());
+                    throw new System.ArgumentException("cannot store numeric type " + numericType);
                 }
                 @string = null;
                 bytes = null;
@@ -218,21 +221,21 @@ namespace Lucene.Net.Codecs.Lucene40
             }
             else
             {
-                if (number is sbyte || number is short || number is int)
+                if (typeof(byte).Equals(numericType) || typeof(short).Equals(numericType) || typeof(int).Equals(numericType))
                 {
-                    fieldsStream.WriteInt32((int)number);
+                    fieldsStream.WriteInt32(field.GetInt32Value().Value);
                 }
-                else if (number is long)
+                else if (typeof(long).Equals(numericType))
                 {
-                    fieldsStream.WriteInt64((long)number);
+                    fieldsStream.WriteInt64(field.GetInt64Value().Value);
                 }
-                else if (number is float)
+                else if (typeof(float).Equals(numericType))
                 {
-                    fieldsStream.WriteInt32(Number.SingleToInt32Bits((float)number));
+                    fieldsStream.WriteInt32(Number.SingleToInt32Bits(field.GetSingleValue().Value));
                 }
-                else if (number is double)
+                else if (typeof(double).Equals(numericType))
                 {
-                    fieldsStream.WriteInt64(BitConverter.DoubleToInt64Bits((double)number));
+                    fieldsStream.WriteInt64(BitConverter.DoubleToInt64Bits(field.GetDoubleValue().Value));
                 }
                 else
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net/Document/Field.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/Field.cs b/src/Lucene.Net/Document/Field.cs
index 793b047..d7fea34 100644
--- a/src/Lucene.Net/Document/Field.cs
+++ b/src/Lucene.Net/Document/Field.cs
@@ -3,6 +3,7 @@ using Lucene.Net.Analysis.TokenAttributes;
 using Lucene.Net.Index;
 using Lucene.Net.Util;
 using System;
+using System.Globalization;
 using System.IO;
 using System.Text;
 
@@ -288,6 +289,7 @@ namespace Lucene.Net.Documents
         /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
         /// <see cref="GetBinaryValue()"/> must be set.
         /// </summary>
+        /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
         public virtual string GetStringValue() // LUCENENET specific: Added verb Get to make it more clear that this returns the value
         {
             if (m_fieldsData is string || m_fieldsData is Number)
@@ -305,7 +307,10 @@ namespace Lucene.Net.Documents
         /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
         /// <see cref="GetBinaryValue()"/> must be set.
         /// </summary>
-        public virtual string GetStringValue(IFormatProvider provider) // LUCENENET specific: Added verb Get to make it more clear that this returns the value
+        /// <param name="provider">An object that supplies culture-specific formatting information. This parameter has no effect if this field is non-numeric.</param>
+        /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+        // LUCENENET specific overload.
+        public virtual string GetStringValue(IFormatProvider provider) 
         {
             if (m_fieldsData is string)
             {
@@ -321,7 +326,15 @@ namespace Lucene.Net.Documents
             }
         }
 
-        public virtual string GetStringValue(string format) // LUCENENET specific: Added verb Get to make it more clear that this returns the value
+        /// <summary>
+        /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+        /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+        /// <see cref="GetBinaryValue()"/> must be set.
+        /// </summary>
+        /// <param name="format">A standard or custom numeric format string. This parameter has no effect if this field is non-numeric.</param>
+        /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+        // LUCENENET specific overload.
+        public virtual string GetStringValue(string format) 
         {
             if (m_fieldsData is string)
             {
@@ -337,7 +350,16 @@ namespace Lucene.Net.Documents
             }
         }
 
-        public virtual string GetStringValue(string format, IFormatProvider provider) // LUCENENET specific: Added verb Get to make it more clear that this returns the value
+        /// <summary>
+        /// The value of the field as a <see cref="string"/>, or <c>null</c>. If <c>null</c>, the <see cref="TextReader"/> value or
+        /// binary value is used. Exactly one of <see cref="GetStringValue()"/>, <see cref="GetReaderValue()"/>, and
+        /// <see cref="GetBinaryValue()"/> must be set.
+        /// </summary>
+        /// <param name="format">A standard or custom numeric format string. This parameter has no effect if this field is non-numeric.</param>
+        /// <param name="provider">An object that supplies culture-specific formatting information. This parameter has no effect if this field is non-numeric.</param>
+        /// <returns>The string representation of the value if it is either a <see cref="string"/> or numeric type.</returns>
+        // LUCENENET specific overload.
+        public virtual string GetStringValue(string format, IFormatProvider provider)
         {
             if (m_fieldsData is string)
             {
@@ -572,6 +594,7 @@ namespace Lucene.Net.Documents
             }
         }
 
+        [Obsolete("In .NET, use of this method will cause boxing/unboxing. Instead, call GetNumericType() to check the underlying type and call the appropriate GetXXXValue() method to retrieve the value.")]
         public virtual object GetNumericValue() // LUCENENET specific: Added verb Get to make it more clear that this returns the value
         {
             // LUCENENET NOTE: Originally, there was a conversion from string to a numeric value here.
@@ -608,6 +631,50 @@ namespace Lucene.Net.Documents
             return null;
         }
 
+        /// <summary>
+        /// Gets the <see cref="Type"/> of the underlying value, or <c>null</c> if the value is not set or non-numeric.
+        /// <para/>
+        /// LUCENENET specific. In Java, the numeric type was determined by checking the type of  
+        /// <see cref="GetNumericValue()"/>. However, since there are no reference number
+        /// types in .NET, using <see cref="GetNumericValue()"/> so will cause boxing/unboxing. It is
+        /// therefore recommended to call this method to check the underlying type and the corresponding 
+        /// <c>Get*Value()</c> method to retrieve the value.
+        /// </summary>
+        public virtual Type GetNumericType() 
+        {
+            if (m_fieldsData is Int32)
+            {
+                return typeof(int);
+            }
+            else if (m_fieldsData is Int64)
+            {
+                return typeof(long);
+            }
+            else if (m_fieldsData is Single)
+            {
+                return typeof(float);
+            }
+            else if (m_fieldsData is Double)
+            {
+                return typeof(double);
+            }
+            else if (m_fieldsData is Int16)
+            {
+                return typeof(short);
+            }
+            else if (m_fieldsData is Byte)
+            {
+                return typeof(byte);
+            }
+
+            return null;
+        }
+
+        /// <summary>
+        /// Returns the field value as <see cref="byte"/> or <c>null</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
         // LUCENENET specific - created overload for Byte, since we have no Number class in .NET
         public virtual byte? GetByteValue()
         {
@@ -621,6 +688,11 @@ namespace Lucene.Net.Documents
             }
         }
 
+        /// <summary>
+        /// Returns the field value as <see cref="short"/> or <c>null</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
         // LUCENENET specific - created overload for Short, since we have no Number class in .NET
         public virtual short? GetInt16Value()
         {
@@ -634,6 +706,11 @@ namespace Lucene.Net.Documents
             }
         }
 
+        /// <summary>
+        /// Returns the field value as <see cref="int"/> or <c>null</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
         // LUCENENET specific - created overload for Int32, since we have no Number class in .NET
         public virtual int? GetInt32Value()
         {
@@ -647,6 +724,11 @@ namespace Lucene.Net.Documents
             }
         }
 
+        /// <summary>
+        /// Returns the field value as <see cref="long"/> or <c>null</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
         // LUCENENET specific - created overload for Int64, since we have no Number class in .NET
         public virtual long? GetInt64Value()
         {
@@ -660,6 +742,11 @@ namespace Lucene.Net.Documents
             }
         }
 
+        /// <summary>
+        /// Returns the field value as <see cref="float"/> or <c>null</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
         // LUCENENET specific - created overload for Single, since we have no Number class in .NET
         public virtual float? GetSingleValue()
         {
@@ -673,6 +760,11 @@ namespace Lucene.Net.Documents
             }
         }
 
+        /// <summary>
+        /// Returns the field value as <see cref="double"/> or <c>null</c> if the type
+        /// is non-numeric.
+        /// </summary>
+        /// <returns>The field value or <c>null</c> if the type is non-numeric.</returns>
         // LUCENENET specific - created overload for Double, since we have no Number class in .NET
         public virtual double? GetDoubleValue()
         {
@@ -686,7 +778,8 @@ namespace Lucene.Net.Documents
             }
         }
 
-
+        /// <summary>
+        /// Non-null if this field has a binary value. </summary>
         public virtual BytesRef GetBinaryValue() // LUCENENET specific: Added verb Get to make it more clear that this returns the value
         {
             if (m_fieldsData is BytesRef)
@@ -728,7 +821,7 @@ namespace Lucene.Net.Documents
         }
 
         /// <summary>
-        /// Returns the <see cref="Documents.FieldType"/> for this field as type <see cref="IIndexableFieldType"/> </summary>
+        /// Returns the <see cref="Documents.FieldType"/> for this field as type <see cref="IIndexableFieldType"/>. </summary>
         public virtual IIndexableFieldType IndexableFieldType
         {
             get { return m_type; }
@@ -776,9 +869,14 @@ namespace Lucene.Net.Documents
                 return internalTokenStream;
             }
 
+            // LUCENENET specific - If the underlying type is numeric, we need
+            // to ensure it is setup to be round-tripped.
+            string format = (numericType == NumericType.SINGLE || numericType == NumericType.DOUBLE) ? "R" : null;
+            string stringValue = GetStringValue(format, CultureInfo.InvariantCulture);
+
             if (!IndexableFieldType.IsTokenized)
             {
-                if (GetStringValue() == null)
+                if (stringValue == null)
                 {
                     throw new System.ArgumentException("Non-Tokenized Fields must have a String value");
                 }
@@ -788,7 +886,7 @@ namespace Lucene.Net.Documents
                     // (attributes,...) if not needed (stored field loading)
                     internalTokenStream = new StringTokenStream();
                 }
-                ((StringTokenStream)internalTokenStream).SetValue(GetStringValue()); // LUCENENET TODO: API Make overload that accepts format/provider
+                ((StringTokenStream)internalTokenStream).SetValue(stringValue);
                 return internalTokenStream;
             }
 
@@ -800,9 +898,9 @@ namespace Lucene.Net.Documents
             {
                 return analyzer.GetTokenStream(Name, GetReaderValue());
             }
-            else if (GetStringValue() != null)
+            else if (stringValue != null)
             {
-                TextReader sr = new StringReader(GetStringValue()); // LUCENENET TODO: API Make overload that accepts format/provider
+                TextReader sr = new StringReader(stringValue);
                 return analyzer.GetTokenStream(Name, sr);
             }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c22ef079/src/Lucene.Net/Index/DocValuesProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Index/DocValuesProcessor.cs b/src/Lucene.Net/Index/DocValuesProcessor.cs
index 0e820f0..0c1835b 100644
--- a/src/Lucene.Net/Index/DocValuesProcessor.cs
+++ b/src/Lucene.Net/Index/DocValuesProcessor.cs
@@ -1,3 +1,4 @@
+using Lucene.Net.Documents;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -72,11 +73,12 @@ namespace Lucene.Net.Index
                 }
                 else if (dvType == DocValuesType.NUMERIC)
                 {
-                    if (!(field.GetNumericValue() is long?))
+                    Type numericType = field.GetNumericType();
+                    if (!(typeof(long).Equals(numericType)))
                     {
-                        throw new System.ArgumentException("illegal type " + field.GetNumericValue().GetType() + ": DocValues types must be Long");
+                        throw new System.ArgumentException("illegal type " + numericType + ": DocValues types must be " + typeof(long));
                     }
-                    AddNumericField(fieldInfo, docID, (long)field.GetNumericValue());
+                    AddNumericField(fieldInfo, docID, field.GetInt64ValueOrDefault());
                 }
                 else
                 {