Mapper: Ability to disable storing the "source" field, closes #66.
This commit is contained in:
parent
6243f4f95b
commit
3a55998a3b
|
@ -394,6 +394,6 @@ public class JsonDocumentMapper implements DocumentMapper, ToJson {
|
|||
}
|
||||
|
||||
@Override public void toJson(JsonBuilder builder, Params params) throws IOException {
|
||||
rootObjectMapper.toJson(builder, params, allFieldMapper);
|
||||
rootObjectMapper.toJson(builder, params, allFieldMapper, sourceFieldMapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import static org.elasticsearch.index.mapper.json.JsonMapperBuilders.*;
|
|||
import static org.elasticsearch.util.json.JacksonNodes.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class JsonDocumentMapperParser implements DocumentMapperParser {
|
||||
|
||||
|
@ -197,6 +197,9 @@ public class JsonDocumentMapperParser implements DocumentMapperParser {
|
|||
Map.Entry<String, JsonNode> entry = fieldsIt.next();
|
||||
String fieldName = entry.getKey();
|
||||
JsonNode fieldNode = entry.getValue();
|
||||
if (fieldName.equals("enabled")) {
|
||||
builder.enabled(nodeBooleanValue(fieldNode));
|
||||
}
|
||||
// if (fieldName.equals("compressionThreshold")) {
|
||||
// builder.compressionThreshold(nodeIn...);
|
||||
// } else if (fieldName.equals("compressionType")) {
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.util.lucene.Lucene;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class JsonSourceFieldMapper extends JsonFieldMapper<byte[]> implements SourceFieldMapper {
|
||||
|
||||
|
@ -51,11 +51,10 @@ public class JsonSourceFieldMapper extends JsonFieldMapper<byte[]> implements So
|
|||
super(Defaults.NAME);
|
||||
}
|
||||
|
||||
// source is always enabled for now
|
||||
// public Builder enabled(boolean enabled) {
|
||||
// this.enabled = enabled;
|
||||
// return this;
|
||||
// }
|
||||
public Builder enabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public JsonSourceFieldMapper build(BuilderContext context) {
|
||||
return new JsonSourceFieldMapper(name, enabled);
|
||||
|
@ -130,7 +129,10 @@ public class JsonSourceFieldMapper extends JsonFieldMapper<byte[]> implements So
|
|||
}
|
||||
|
||||
@Override public void toJson(JsonBuilder builder, Params params) throws IOException {
|
||||
// for now, don't output it at all
|
||||
builder.startObject(jsonType());
|
||||
builder.field("name", name());
|
||||
builder.field("enabled", enabled);
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
@Override public void merge(JsonMapper mergeWith, JsonMergeContext mergeContext) throws MergeMappingException {
|
||||
|
|
Loading…
Reference in New Issue