mirror of https://github.com/apache/lucene.git
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:
parent
31da6a3535
commit
56b0a46f10
|
@ -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
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue