BUG: Lucene.Net.Core.Document.Field: Parsing string value into a long was 
causing issues with the TestLazyDocument.TestLazy() test, which was calling the 
wrong StoredFieldsVisitor method because of the data type change.


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

Branch: refs/heads/api-work
Commit: d252c683c184c4d183b2dc0e8675e5334c1fd5a5
Parents: edd30a5
Author: Shad Storhaug <[email protected]>
Authored: Wed Mar 8 22:49:10 2017 +0700
Committer: Shad Storhaug <[email protected]>
Committed: Thu Mar 9 01:11:06 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Document/Field.cs                | 15 +++++----------
 .../Document/TestLazyDocument.cs                     |  2 +-
 2 files changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d252c683/src/Lucene.Net.Core/Document/Field.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/Field.cs 
b/src/Lucene.Net.Core/Document/Field.cs
index 9412b7f..91cc425 100644
--- a/src/Lucene.Net.Core/Document/Field.cs
+++ b/src/Lucene.Net.Core/Document/Field.cs
@@ -499,16 +499,11 @@ namespace Lucene.Net.Documents
 
         public virtual object GetNumericValue() // LUCENENET specific: Added 
verb Get to make it more clear that this returns the value
         {
-            // LUCENENET TODO: There was no expensive conversion from string 
in the original
-            string str = m_fieldsData as string;
-            if (str != null)
-            {
-                long ret;
-                if (long.TryParse(str, out ret))
-                {
-                    return ret;
-                }
-            }
+            // LUCENENET NOTE: Originally, there was a conversion from string 
to a numeric value here.
+            // This was causing the 
Lucene.Net.Documents.TestLazyDocument.TestLazy() test (in 
Lucene.Net.Tests.Misc) to fail.
+            // It is important that if numeric data is provided as a string to 
the field that it remains a string or the
+            // 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)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d252c683/src/Lucene.Net.Tests.Misc/Document/TestLazyDocument.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Misc/Document/TestLazyDocument.cs 
b/src/Lucene.Net.Tests.Misc/Document/TestLazyDocument.cs
index cacef9e..bff4a27 100644
--- a/src/Lucene.Net.Tests.Misc/Document/TestLazyDocument.cs
+++ b/src/Lucene.Net.Tests.Misc/Document/TestLazyDocument.cs
@@ -117,7 +117,7 @@ namespace Lucene.Net.Documents
                     }
                 }
                 Console.WriteLine("numFieldValues == " + numFieldValues);
-                assertEquals("numFieldValues", 1 + (NUM_VALUES * 
FIELDS.Length), // LUCENENET TODO: Failing here 1 too small, but what field is 
the + 1 here supposed to represent?
+                assertEquals("numFieldValues", 1 + (NUM_VALUES * 
FIELDS.Length),
                              numFieldValues);
 
                 foreach (string field in fieldValueCounts.Keys)

Reply via email to