|
25 | 25 | import java.util.List;
|
26 | 26 | import java.util.Map;
|
27 | 27 |
|
| 28 | +import org.elasticsearch.common.lang3.StringUtils; |
28 | 29 | import org.elasticsearch.common.xcontent.XContentBuilder;
|
29 | 30 | import org.springframework.core.GenericCollectionTypeResolver;
|
30 | 31 | import org.springframework.data.annotation.Transient;
|
@@ -65,6 +66,8 @@ class MappingBuilder {
|
65 | 66 | public static final String TYPE_VALUE_STRING = "string";
|
66 | 67 | public static final String TYPE_VALUE_GEO_POINT = "geo_point";
|
67 | 68 | public static final String TYPE_VALUE_COMPLETION = "completion";
|
| 69 | + public static final String TYPE_VALUE_GEO_HASH_PREFIX = "geohash_prefix" ; |
| 70 | + public static final String TYPE_VALUE_GEO_HASH_PRECISION = "geohash_precision"; |
68 | 71 |
|
69 | 72 | private static SimpleTypeHolder SIMPLE_TYPE_HOLDER = new SimpleTypeHolder();
|
70 | 73 |
|
@@ -169,8 +172,18 @@ private static boolean isAnnotated(java.lang.reflect.Field field) {
|
169 | 172 |
|
170 | 173 | private static void applyGeoPointFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field) throws IOException {
|
171 | 174 | xContentBuilder.startObject(field.getName());
|
172 |
| - xContentBuilder.field(FIELD_TYPE, TYPE_VALUE_GEO_POINT) |
173 |
| - .endObject(); |
| 175 | + xContentBuilder.field(FIELD_TYPE, TYPE_VALUE_GEO_POINT); |
| 176 | + |
| 177 | + GeoPointField annotation = field.getAnnotation(GeoPointField.class); |
| 178 | + if (annotation != null) { |
| 179 | + if (annotation.geoHashPrefix()) |
| 180 | + xContentBuilder.field(TYPE_VALUE_GEO_HASH_PREFIX, true); |
| 181 | + |
| 182 | + if (StringUtils.isNotEmpty(annotation.geoHashPrecision())) |
| 183 | + xContentBuilder.field(TYPE_VALUE_GEO_HASH_PRECISION, annotation.geoHashPrecision()); |
| 184 | + } |
| 185 | + |
| 186 | + xContentBuilder.endObject(); |
174 | 187 | }
|
175 | 188 |
|
176 | 189 | private static void applyCompletionFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field, CompletionField annotation) throws IOException {
|
|
0 commit comments