slim down the mapping serialization to xcontent (json), don't write default values
This commit is contained in:
parent
e44604b441
commit
7340d6973d
|
@ -30,7 +30,7 @@ import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
|||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface FieldMapper<T> {
|
||||
|
|
|
@ -396,13 +396,16 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, XContent
|
|||
|
||||
protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
builder.field("type", contentType());
|
||||
if (!names.name().equals(names.indexNameClean())) {
|
||||
builder.field("index_name", names.indexNameClean());
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (boost != 1.0f) {
|
||||
builder.field("boost", boost);
|
||||
builder.field("omit_norms", omitNorms);
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (indexAnalyzer != null && searchAnalyzer != null && indexAnalyzer.name().equals(searchAnalyzer.name()) && !indexAnalyzer.name().startsWith("_")) {
|
||||
// same analyzers, output it once
|
||||
builder.field("analyzer", indexAnalyzer.name());
|
||||
} else {
|
||||
if (indexAnalyzer != null && !indexAnalyzer.name().startsWith("_")) {
|
||||
builder.field("index_analyzer", indexAnalyzer.name());
|
||||
}
|
||||
|
@ -410,6 +413,7 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, XContent
|
|||
builder.field("search_analyzer", searchAnalyzer.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String contentType();
|
||||
}
|
||||
|
|
|
@ -154,16 +154,31 @@ public class AllFieldMapper extends AbstractFieldMapper<Void> implements org.ela
|
|||
}
|
||||
|
||||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no need to write it at all
|
||||
if (enabled == Defaults.ENABLED && store == Defaults.STORE && termVector == Defaults.TERM_VECTOR && indexAnalyzer == null && searchAnalyzer == null) {
|
||||
return;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (enabled != Defaults.ENABLED) {
|
||||
builder.field("enabled", enabled);
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (indexAnalyzer != null && searchAnalyzer != null && indexAnalyzer.name().equals(searchAnalyzer.name()) && !indexAnalyzer.name().startsWith("_")) {
|
||||
// same analyzers, output it once
|
||||
builder.field("analyzer", indexAnalyzer.name());
|
||||
} else {
|
||||
if (indexAnalyzer != null && !indexAnalyzer.name().startsWith("_")) {
|
||||
builder.field("index_analyzer", indexAnalyzer.name());
|
||||
}
|
||||
if (searchAnalyzer != null && !searchAnalyzer.name().startsWith("_")) {
|
||||
builder.field("search_analyzer", searchAnalyzer.name());
|
||||
}
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,9 @@ public class BinaryFieldMapper extends AbstractFieldMapper<byte[]> {
|
|||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(names.name());
|
||||
builder.field("type", contentType());
|
||||
if (!names.name().equals(names.indexNameClean())) {
|
||||
builder.field("index_name", names.indexNameClean());
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
|
@ -167,6 +167,21 @@ public class BooleanFieldMapper extends AbstractFieldMapper<Boolean> {
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -176,8 +176,14 @@ public class BoostFieldMapper extends NumberFieldMapper<Float> implements org.el
|
|||
}
|
||||
|
||||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// all are defaults, don't write it at all
|
||||
if (name().equals(Defaults.NAME) && nullValue == null) {
|
||||
return;
|
||||
}
|
||||
builder.startObject(contentType());
|
||||
if (!name().equals(Defaults.NAME)) {
|
||||
builder.field("name", name());
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -222,6 +222,24 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
builder.field("format", dateTimeFormatter.format());
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
|
|
|
@ -205,6 +205,24 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -205,6 +205,24 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -121,8 +121,14 @@ public class IdFieldMapper extends AbstractFieldMapper<String> implements org.el
|
|||
}
|
||||
|
||||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no sense to write it at all
|
||||
if (store == Defaults.STORE) {
|
||||
return;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -128,9 +128,17 @@ public class IndexFieldMapper extends AbstractFieldMapper<String> implements org
|
|||
}
|
||||
|
||||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all defaults, no need to write it at all
|
||||
if (store == Defaults.STORE && enabled == Defaults.ENABLED) {
|
||||
return;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (enabled != Defaults.ENABLED) {
|
||||
builder.field("enabled", enabled);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -204,6 +204,24 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -237,6 +237,24 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -204,6 +204,24 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -266,7 +266,9 @@ public class MultiFieldMapper implements XContentMapper, IncludeInAllMapper {
|
|||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(name);
|
||||
builder.field("type", CONTENT_TYPE);
|
||||
if (pathType != Defaults.PATH_TYPE) {
|
||||
builder.field("path", pathType.name().toLowerCase());
|
||||
}
|
||||
|
||||
builder.startObject("fields");
|
||||
if (defaultMapper != null) {
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.lucene.search.Query;
|
|||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.thread.ThreadLocals;
|
||||
import org.elasticsearch.common.trove.TIntObjectHashMap;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
@ -166,16 +165,11 @@ public abstract class NumberFieldMapper<T extends Number> extends AbstractFieldM
|
|||
}
|
||||
}
|
||||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
|
||||
@Override public abstract FieldDataType fieldDataType();
|
||||
|
||||
/**
|
||||
* Removes a cached numeric token stream. The stream will be returned to the cahed once it is used
|
||||
* sicne it implements the end method.
|
||||
* Removes a cached numeric token stream. The stream will be returned to the cached once it is used
|
||||
* since it implements the end method.
|
||||
*/
|
||||
protected CachedNumericTokenStream popCachedStream(int precisionStep) {
|
||||
Deque<CachedNumericTokenStream> deque = cachedStreams.get().get().get(precisionStep);
|
||||
|
|
|
@ -551,10 +551,18 @@ public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
|
|||
|
||||
public void toXContent(XContentBuilder builder, Params params, XContentMapper... additionalMappers) throws IOException {
|
||||
builder.startObject(name);
|
||||
if (mappers.isEmpty()) { // only write the object content type if there are no properties, otherwise, it is automatically detected
|
||||
builder.field("type", CONTENT_TYPE);
|
||||
}
|
||||
if (dynamic != Defaults.DYNAMIC) {
|
||||
builder.field("dynamic", dynamic);
|
||||
}
|
||||
if (enabled != Defaults.ENABLED) {
|
||||
builder.field("enabled", enabled);
|
||||
}
|
||||
if (pathType != Defaults.PATH_TYPE) {
|
||||
builder.field("path", pathType.name().toLowerCase());
|
||||
}
|
||||
if (includeInAll != null) {
|
||||
builder.field("include_in_all", includeInAll);
|
||||
}
|
||||
|
|
|
@ -93,14 +93,17 @@ public class RootObjectMapper extends ObjectMapper {
|
|||
|
||||
|
||||
@Override protected ObjectMapper createMapper(String name, boolean enabled, boolean dynamic, ContentPath.Type pathType, Map<String, XContentMapper> mappers) {
|
||||
FormatDateTimeFormatter[] dates = null;
|
||||
if (dateTimeFormatters == null) {
|
||||
dateTimeFormatters = newArrayList();
|
||||
dates = new FormatDateTimeFormatter[0];
|
||||
} else if (dateTimeFormatters.isEmpty()) {
|
||||
// add the default one
|
||||
dateTimeFormatters.addAll(newArrayList(Defaults.DATE_TIME_FORMATTERS));
|
||||
dates = Defaults.DATE_TIME_FORMATTERS;
|
||||
} else {
|
||||
dates = dateTimeFormatters.toArray(new FormatDateTimeFormatter[dateTimeFormatters.size()]);
|
||||
}
|
||||
return new RootObjectMapper(name, enabled, dynamic, pathType, mappers,
|
||||
dateTimeFormatters.toArray(new FormatDateTimeFormatter[dateTimeFormatters.size()]),
|
||||
dates,
|
||||
dynamicTemplates.toArray(new DynamicTemplate[dynamicTemplates.size()]));
|
||||
}
|
||||
}
|
||||
|
@ -206,6 +209,7 @@ public class RootObjectMapper extends ObjectMapper {
|
|||
}
|
||||
|
||||
@Override protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
if (dateTimeFormatters != Defaults.DATE_TIME_FORMATTERS) {
|
||||
if (dateTimeFormatters.length > 0) {
|
||||
builder.startArray("date_formats");
|
||||
for (FormatDateTimeFormatter dateTimeFormatter : dateTimeFormatters) {
|
||||
|
@ -213,6 +217,7 @@ public class RootObjectMapper extends ObjectMapper {
|
|||
}
|
||||
builder.endArray();
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamicTemplates != null && dynamicTemplates.length > 0) {
|
||||
builder.startArray("dynamic_templates");
|
||||
|
|
|
@ -204,6 +204,24 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (precisionStep != Defaults.PRECISION_STEP) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -168,9 +168,14 @@ public class SourceFieldMapper extends AbstractFieldMapper<byte[]> implements or
|
|||
}
|
||||
|
||||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// all are defaults, no need to write it at all
|
||||
if (enabled == Defaults.ENABLED && compress == null) {
|
||||
return;
|
||||
}
|
||||
builder.startObject(contentType());
|
||||
builder.field("name", name());
|
||||
if (enabled != Defaults.ENABLED) {
|
||||
builder.field("enabled", enabled);
|
||||
}
|
||||
if (compress != null) {
|
||||
builder.field("compress", compress);
|
||||
}
|
||||
|
|
|
@ -166,6 +166,21 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements In
|
|||
|
||||
@Override protected void doXContentBody(XContentBuilder builder) throws IOException {
|
||||
super.doXContentBody(builder);
|
||||
if (index != Defaults.INDEX) {
|
||||
builder.field("index", index.name().toLowerCase());
|
||||
}
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
if (termVector != Defaults.TERM_VECTOR) {
|
||||
builder.field("term_vector", termVector.name().toLowerCase());
|
||||
}
|
||||
if (omitNorms != Defaults.OMIT_NORMS) {
|
||||
builder.field("omit_norms", omitNorms);
|
||||
}
|
||||
if (omitTermFreqAndPositions != Defaults.OMIT_TERM_FREQ_AND_POSITIONS) {
|
||||
builder.field("omit_term_freq_and_positions", omitTermFreqAndPositions);
|
||||
}
|
||||
if (nullValue != null) {
|
||||
builder.field("null_value", nullValue);
|
||||
}
|
||||
|
|
|
@ -110,8 +110,14 @@ public class TypeFieldMapper extends AbstractFieldMapper<String> implements org.
|
|||
}
|
||||
|
||||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// if all are defaults, no sense to write it at all
|
||||
if (store == Defaults.STORE) {
|
||||
return;
|
||||
}
|
||||
builder.startObject(CONTENT_TYPE);
|
||||
if (store != Defaults.STORE) {
|
||||
builder.field("store", store.name().toLowerCase());
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -66,19 +66,22 @@ public class GeoPointFieldMapper implements XContentMapper, ArrayValueMapperPars
|
|||
public static class Defaults {
|
||||
public static final ContentPath.Type PATH_TYPE = ContentPath.Type.FULL;
|
||||
public static final Field.Store STORE = Field.Store.NO;
|
||||
public static final boolean ENABLE_LATLON = false;
|
||||
public static final boolean ENABLE_GEOHASH = false;
|
||||
public static final int PRECISION = GeoHashUtils.PRECISION;
|
||||
}
|
||||
|
||||
public static class Builder extends XContentMapper.Builder<Builder, GeoPointFieldMapper> {
|
||||
|
||||
private ContentPath.Type pathType = Defaults.PATH_TYPE;
|
||||
|
||||
private boolean enableGeoHash = false;
|
||||
private boolean enableGeoHash = Defaults.ENABLE_GEOHASH;
|
||||
|
||||
private boolean enableLatLon = false;
|
||||
private boolean enableLatLon = Defaults.ENABLE_LATLON;
|
||||
|
||||
private Integer precisionStep;
|
||||
|
||||
private int precision = GeoHashUtils.PRECISION;
|
||||
private int precision = Defaults.PRECISION;
|
||||
|
||||
private Field.Store store = Defaults.STORE;
|
||||
|
||||
|
@ -354,11 +357,21 @@ public class GeoPointFieldMapper implements XContentMapper, ArrayValueMapperPars
|
|||
@Override public void toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(name);
|
||||
builder.field("type", CONTENT_TYPE);
|
||||
if (pathType != Defaults.PATH_TYPE) {
|
||||
builder.field("path", pathType.name().toLowerCase());
|
||||
}
|
||||
if (enableLatLon != Defaults.ENABLE_LATLON) {
|
||||
builder.field("lat_lon", enableLatLon);
|
||||
}
|
||||
if (enableGeoHash != Defaults.ENABLE_GEOHASH) {
|
||||
builder.field("geohash", enableGeoHash);
|
||||
}
|
||||
if (geoStringMapper.store() != Defaults.STORE) {
|
||||
builder.field("store", geoStringMapper.store().name().toLowerCase());
|
||||
}
|
||||
if (precision != Defaults.PRECISION) {
|
||||
builder.field("geohash_precision", precision);
|
||||
}
|
||||
if (precisionStep != null) {
|
||||
builder.field("precision_step", precisionStep);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class UpdateNumberOfReplicasTests extends AbstractNodesTests {
|
|||
Thread.sleep(200);
|
||||
|
||||
logger.info("Running Cluster Health");
|
||||
clusterHealth = client1.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
|
||||
clusterHealth = client1.admin().cluster().prepareHealth().setWaitForYellowStatus().setWaitForActiveShards(10).execute().actionGet();
|
||||
logger.info("Done Cluster Health, status " + clusterHealth.status());
|
||||
assertThat(clusterHealth.timedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.YELLOW));
|
||||
|
|
Loading…
Reference in New Issue