Merge GeoPoint specific mapping properties

Close #5505
This commit is contained in:
Kevin Wang 2014-03-24 13:25:16 +11:00 committed by Adrien Grand
parent c650ee47f3
commit bfd3236378
2 changed files with 38 additions and 3 deletions

View File

@ -154,6 +154,10 @@ is `true`).
|`normalize_lat` |Set to `true` to normalize latitude. |`normalize_lat` |Set to `true` to normalize latitude.
|`normalize_lon` |Set to `true` to normalize longitude. |`normalize_lon` |Set to `true` to normalize longitude.
|`precision_step` |The precision step (number of terms generated for
each number value) for `.lat` and `.lon` fields if `lat_lon` is set to `true`.
Defaults to `4`.
|======================================================================= |=======================================================================
[float] [float]

View File

@ -394,8 +394,8 @@ public class GeoPointFieldMapper extends AbstractFieldMapper<GeoPoint> implement
private final StringFieldMapper geohashMapper; private final StringFieldMapper geohashMapper;
private final boolean validateLon; private boolean validateLon;
private final boolean validateLat; private boolean validateLat;
private final boolean normalizeLon; private final boolean normalizeLon;
private final boolean normalizeLat; private final boolean normalizeLat;
@ -613,7 +613,38 @@ public class GeoPointFieldMapper extends AbstractFieldMapper<GeoPoint> implement
@Override @Override
public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException { public void merge(Mapper mergeWith, MergeContext mergeContext) throws MergeMappingException {
super.merge(mergeWith, mergeContext); super.merge(mergeWith, mergeContext);
// TODO: geo-specific properties if (!this.getClass().equals(mergeWith.getClass())) {
return;
}
GeoPointFieldMapper fieldMergeWith = (GeoPointFieldMapper) mergeWith;
if (this.enableLatLon != fieldMergeWith.enableLatLon) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different lat_lon");
}
if (this.enableGeoHash != fieldMergeWith.enableGeoHash) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different geohash");
}
if (this.geoHashPrecision != fieldMergeWith.geoHashPrecision) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different geohash_precision");
}
if (this.enableGeohashPrefix != fieldMergeWith.enableGeohashPrefix) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different geohash_prefix");
}
if (this.normalizeLat != fieldMergeWith.normalizeLat) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different normalize_lat");
}
if (this.normalizeLon != fieldMergeWith.normalizeLon) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different normalize_lon");
}
if (this.precisionStep != fieldMergeWith.precisionStep) {
mergeContext.addConflict("mapper [" + names.fullName() + "] has different precision_step");
}
if (!mergeContext.mergeFlags().simulate()) {
this.validateLat = fieldMergeWith.validateLat;
this.validateLon = fieldMergeWith.validateLon;
}
} }
@Override @Override