Fixing index information retrieval

- Storing doubles instead of floats
- Fixing integer values parsing

--HG--
branch : dev
extra : transplant_source : %EB%7E%27%E7%3B%2B%CEvA%AE%90%3FQ%BE%9Bw%9C%3FXA
This commit is contained in:
Sebastien Ros
2011-01-21 09:01:56 -08:00
parent fcd3fbfb22
commit 3826bc606f
6 changed files with 39 additions and 12 deletions

View File

@@ -15,7 +15,7 @@ namespace Lucene.Models {
private string _name;
private string _stringValue;
private int _intValue;
private float _floatValue;
private double _doubleValue;
private bool _analyze;
private bool _store;
private bool _removeTags;
@@ -46,7 +46,7 @@ namespace Lucene.Models {
}
public IDocumentIndex Add(string name, DateTime value) {
return Add(name, DateTools.DateToString(value, DateTools.Resolution.SECOND));
return Add(name, DateTools.DateToString(value, DateTools.Resolution.MILLISECOND));
}
public IDocumentIndex Add(string name, int value) {
@@ -62,10 +62,10 @@ namespace Lucene.Models {
return Add(name, value.ToString());
}
public IDocumentIndex Add(string name, float value) {
public IDocumentIndex Add(string name, double value) {
PrepareForIndexing();
_name = name;
_floatValue = value;
_doubleValue = value;
_typeCode = TypeCode.Single;
IsDirty = true;
return this;
@@ -114,7 +114,7 @@ namespace Lucene.Models {
case TypeCode.Single:
Fields.Add(new NumericField(_name,
_store ? Field.Store.YES : Field.Store.NO,
true).SetFloatValue(_floatValue));
true).SetDoubleValue(_doubleValue));
break;
case TypeCode.Empty:
break;

View File

@@ -20,12 +20,12 @@ namespace Lucene.Models {
public int GetInt(string name) {
var field = _doc.GetField(name);
return field == null ? 0 : NumericUtils.PrefixCodedToInt(field.StringValue());
return field == null ? 0 : Int32.Parse(field.StringValue(), CultureInfo.InvariantCulture);
}
public float GetFloat(string name) {
public double GetDouble(string name) {
var field = _doc.GetField(name);
return field == null ? 0 : float.Parse(field.StringValue(), CultureInfo.InvariantCulture);
return field == null ? 0 : double.Parse(field.StringValue(), CultureInfo.InvariantCulture);
}
public bool GetBoolean(string name) {