@Override public GeoPointFieldMapper build(BuilderContext context) { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); DoubleFieldMapper latMapper = null; DoubleFieldMapper lonMapper = null; GeoPointFieldType geoPointFieldType = (GeoPointFieldType) fieldType; context.path().add(name); if (enableLatLon) { NumberFieldMapper.Builder<?, ?> latMapperBuilder = doubleField(Names.LAT).includeInAll(false); NumberFieldMapper.Builder<?, ?> lonMapperBuilder = doubleField(Names.LON).includeInAll(false); if (precisionStep != null) { latMapperBuilder.precisionStep(precisionStep); lonMapperBuilder.precisionStep(precisionStep); } latMapper = (DoubleFieldMapper) latMapperBuilder .includeInAll(false) .store(fieldType.stored()) .docValues(false) .build(context); lonMapper = (DoubleFieldMapper) lonMapperBuilder .includeInAll(false) .store(fieldType.stored()) .docValues(false) .build(context); geoPointFieldType.setLatLonEnabled(latMapper.fieldType(), lonMapper.fieldType()); } StringFieldMapper geohashMapper = null; if (enableGeoHash || enableGeohashPrefix) { // TODO: possible also implicitly enable geohash if geohash precision is set geohashMapper = stringField(Names.GEOHASH) .index(true) .tokenized(false) .includeInAll(false) .omitNorms(true) .indexOptions(IndexOptions.DOCS) .build(context); geoPointFieldType.setGeohashEnabled( geohashMapper.fieldType(), geoHashPrecision, enableGeohashPrefix); } context.path().remove(); context.path().pathType(origPathType); // this is important: even if geo points feel like they need to be tokenized to distinguish // lat from lon, we actually want to // store them as a single token. fieldType.setTokenized(false); setupFieldType(context); fieldType.setHasDocValues(false); defaultFieldType.setHasDocValues(false); return new GeoPointFieldMapper( name, fieldType, defaultFieldType, context.indexSettings(), origPathType, latMapper, lonMapper, geohashMapper, multiFieldsBuilder.build(this, context)); }