in spark/core/src/main/scala/org/elasticsearch/spark/serialization/ScalaValueReader.scala [76:115]
def readValue(parser: Parser, value: String, esType: FieldType) = {
if (esType == null || parser.currentToken() == VALUE_NULL) {
nullValue()
} else {
esType match {
case NULL => nullValue()
case STRING => textValue(value, parser)
case TEXT => textValue(value, parser)
case KEYWORD => textValue(value, parser)
case WILDCARD => textValue(value, parser)
case BYTE => byteValue(value, parser)
case SHORT => shortValue(value, parser)
case INTEGER => intValue(value, parser)
case TOKEN_COUNT => longValue(value, parser)
case LONG => longValue(value, parser)
case HALF_FLOAT => floatValue(value, parser)
case SCALED_FLOAT => doubleValue(value, parser)
case FLOAT => floatValue(value, parser)
case DOUBLE => doubleValue(value, parser)
case BOOLEAN => booleanValue(value, parser)
case BINARY => binaryValue(Option(parser.binaryValue()).getOrElse(value.getBytes()))
case DATE => date(value, parser)
case DATE_NANOS => dateNanos(value, parser)
// GEO is ambiguous so use the JSON type instead to differentiate between doubles (a lot in GEO_SHAPE) and strings
case GEO_POINT | GEO_SHAPE => {
if (parser.currentToken() == VALUE_NUMBER) doubleValue(value, parser) else textValue(value, parser)
}
// JOIN field is special. Only way that we could have reached here is if the join value we're reading is
// the short-hand format of the join field for parent documents. Make a container and put the value under it.
case JOIN => {
val container = createMap()
addToMap(container, "name", textValue(value, parser))
container
}
// everything else (IP, GEO) gets translated to strings
case _ => textValue(value, parser)
}
}
}