SOLR-8287: TrieDoubleField and TrieLongField now override toNativeType

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1714226 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christine Poerschke 2015-11-13 15:52:02 +00:00
parent 31da6a3535
commit 56b0a46f10
3 changed files with 24 additions and 0 deletions

View File

@ -388,6 +388,9 @@ Bug Fixes
if the last published state is something else if it has already registered with ZK.
(Ishan Chattopadhyaya, Mark Miller via noble)
* SOLR-8287: TrieDoubleField and TrieLongField now override toNativeType
(Ishan Chattopadhyaya via Christine Poerschke)
Optimizations
----------------------

View File

@ -55,6 +55,14 @@ public class TrieDoubleField extends TrieField implements DoubleValueFieldType {
type=TrieTypes.DOUBLE;
}
@Override
public Object toNativeType(Object val) {
if(val==null) return null;
if (val instanceof Number) return ((Number) val).doubleValue();
if (val instanceof String) return Double.parseDouble((String) val);
return super.toNativeType(val);
}
@Override
protected ValueSource getSingleValueSource(SortedSetSelector.Type choice, SchemaField f) {

View File

@ -49,6 +49,19 @@ public class TrieLongField extends TrieField implements LongValueFieldType {
type=TrieTypes.LONG;
}
@Override
public Object toNativeType(Object val) {
if(val==null) return null;
if (val instanceof Number) return ((Number) val).longValue();
try {
if (val instanceof String) return Long.parseLong((String) val);
} catch (NumberFormatException e) {
Double v = Double.parseDouble((String) val);
return v.longValue();
}
return super.toNativeType(val);
}
@Override
protected ValueSource getSingleValueSource(SortedSetSelector.Type choice, SchemaField f) {