org.elasticsearch.index.mapper.DateFieldMapper Java Examples

The following examples show how to use org.elasticsearch.index.mapper.DateFieldMapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalWeatherDataMapper.java    From FlinkExperiments with MIT License 6 votes vote down vote up
@Override
protected void configureRootObjectBuilder(RootObjectMapper.Builder builder) {
    builder
            .add(new DateFieldMapper.Builder("dateTime"))
            .add(new NumberFieldMapper.Builder("temperature", NumberType.FLOAT))
            .add(new NumberFieldMapper.Builder("windSpeed", NumberType.FLOAT))
            .add(new NumberFieldMapper.Builder("stationPressure", NumberType.FLOAT))
            .add(new TextFieldMapper.Builder("skyCondition"))
            .add(new ObjectMapper.Builder("station")
                    .add(new TextFieldMapper.Builder("wban"))
                    .add(new TextFieldMapper.Builder("name"))
                    .add(new TextFieldMapper.Builder("state"))
                    .add(new TextFieldMapper.Builder("location"))
                    .add(new GeoPointFieldMapper.Builder("coordinates"))
                    .nested(ObjectMapper.Nested.newNested(true, false)));
}
 
Example #2
Source File: DateHierarchyAggregationBuilder.java    From elasticsearch-aggregation-pathhierarchy with MIT License 6 votes vote down vote up
public List<RoundingInfo> buildRoundings() {
    List<RoundingInfo> roundings = new ArrayList<>();

    ZoneId timeZone = timeZone() == null ? ZoneOffset.UTC: timeZone();

    for (String interval: INTERVAL_CONFIG.keySet()) {
        roundings.add(new RoundingInfo(interval, createRounding(INTERVAL_CONFIG.get(interval).dateTimeUnit),
                new DocValueFormat.DateTime(DateFormatter.forPattern(INTERVAL_CONFIG.get(interval).format), timeZone,
                        DateFieldMapper.Resolution.MILLISECONDS)));
        if (interval.equals(interval())) {
            break;
        }
    }

    return roundings;
}
 
Example #3
Source File: IndicesModule.java    From crate with Apache License 2.0 5 votes vote down vote up
private Map<String, Mapper.TypeParser> getMappers(List<MapperPlugin> mapperPlugins) {
    Map<String, Mapper.TypeParser> mappers = new LinkedHashMap<>();

    // builtin mappers
    for (NumberFieldMapper.NumberType type : NumberFieldMapper.NumberType.values()) {
        mappers.put(type.typeName(), new NumberFieldMapper.TypeParser(type));
    }
    mappers.put(BooleanFieldMapper.CONTENT_TYPE, new BooleanFieldMapper.TypeParser());
    mappers.put(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser());
    mappers.put(IpFieldMapper.CONTENT_TYPE, new IpFieldMapper.TypeParser());
    mappers.put(TextFieldMapper.CONTENT_TYPE, new TextFieldMapper.TypeParser());
    mappers.put(KeywordFieldMapper.CONTENT_TYPE, new KeywordFieldMapper.TypeParser());
    mappers.put(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser());
    mappers.put(FieldAliasMapper.CONTENT_TYPE, new FieldAliasMapper.TypeParser());
    mappers.put(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser());

    if (ShapesAvailability.JTS_AVAILABLE && ShapesAvailability.SPATIAL4J_AVAILABLE) {
        mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new GeoShapeFieldMapper.TypeParser());
    }

    for (MapperPlugin mapperPlugin : mapperPlugins) {
        for (Map.Entry<String, Mapper.TypeParser> entry : mapperPlugin.getMappers().entrySet()) {
            if (mappers.put(entry.getKey(), entry.getValue()) != null) {
                throw new IllegalArgumentException("Mapper [" + entry.getKey() + "] is already registered");
            }
        }
    }
    return Collections.unmodifiableMap(mappers);
}