mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-29 19:38:29 +00:00
Support parsing Strings with numeric types, closes #54
This commit is contained in:
parent
baaac70da5
commit
ae5bcb6d2e
@ -158,9 +158,13 @@ public class JsonBoostFieldMapper extends JsonNumberFieldMapper<Float> implement
|
||||
return Float.NaN;
|
||||
}
|
||||
value = nullValue;
|
||||
} else {
|
||||
if (jsonContext.jp().getCurrentToken() == JsonToken.VALUE_STRING) {
|
||||
value = Float.parseFloat(jsonContext.jp().getText());
|
||||
} else {
|
||||
value = jsonContext.jp().getFloatValue();
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -115,9 +115,13 @@ public class JsonDoubleFieldMapper extends JsonNumberFieldMapper<Double> {
|
||||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
} else {
|
||||
if (jsonContext.jp().getCurrentToken() == JsonToken.VALUE_STRING) {
|
||||
value = Double.parseDouble(jsonContext.jp().getText());
|
||||
} else {
|
||||
value = jsonContext.jp().getDoubleValue();
|
||||
}
|
||||
}
|
||||
Field field = null;
|
||||
if (stored()) {
|
||||
field = new Field(names.indexName(), Numbers.doubleToBytes(value), store);
|
||||
|
@ -115,9 +115,13 @@ public class JsonFloatFieldMapper extends JsonNumberFieldMapper<Float> {
|
||||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
} else {
|
||||
if (jsonContext.jp().getCurrentToken() == JsonToken.VALUE_STRING) {
|
||||
value = Float.parseFloat(jsonContext.jp().getText());
|
||||
} else {
|
||||
value = jsonContext.jp().getFloatValue();
|
||||
}
|
||||
}
|
||||
Field field = null;
|
||||
if (stored()) {
|
||||
field = new Field(names.indexName(), Numbers.floatToBytes(value), store);
|
||||
|
@ -114,9 +114,13 @@ public class JsonIntegerFieldMapper extends JsonNumberFieldMapper<Integer> {
|
||||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
} else {
|
||||
if (jsonContext.jp().getCurrentToken() == JsonToken.VALUE_STRING) {
|
||||
value = Integer.parseInt(jsonContext.jp().getText());
|
||||
} else {
|
||||
value = jsonContext.jp().getIntValue();
|
||||
}
|
||||
}
|
||||
Field field = null;
|
||||
if (stored()) {
|
||||
field = new Field(names.indexName(), Numbers.intToBytes(value), store);
|
||||
|
@ -114,9 +114,13 @@ public class JsonLongFieldMapper extends JsonNumberFieldMapper<Long> {
|
||||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
} else {
|
||||
if (jsonContext.jp().getCurrentToken() == JsonToken.VALUE_STRING) {
|
||||
value = Long.parseLong(jsonContext.jp().getText());
|
||||
} else {
|
||||
value = jsonContext.jp().getLongValue();
|
||||
}
|
||||
}
|
||||
Field field = null;
|
||||
if (stored()) {
|
||||
field = new Field(names.indexName(), Numbers.longToBytes(value), store);
|
||||
|
Loading…
x
Reference in New Issue
Block a user