Mapper: Rename allFIeld to _all, sourceField to _source, idField to _id, and typeField to _type, closes #105.

This commit is contained in:
kimchy 2010-04-04 01:50:52 +03:00
parent 5da4b0748f
commit 6bf19fcd93
12 changed files with 29 additions and 25 deletions

View File

@ -42,7 +42,7 @@ import static org.elasticsearch.util.lucene.all.AllTokenFilter.*;
*/ */
public class JsonAllFieldMapper extends JsonFieldMapper<Void> implements AllFieldMapper { public class JsonAllFieldMapper extends JsonFieldMapper<Void> implements AllFieldMapper {
public static final String JSON_TYPE = "allField"; public static final String JSON_TYPE = "_all";
public static class Defaults extends JsonFieldMapper.Defaults { public static class Defaults extends JsonFieldMapper.Defaults {
public static final String NAME = AllFieldMapper.NAME; public static final String NAME = AllFieldMapper.NAME;

View File

@ -38,7 +38,7 @@ import java.io.IOException;
*/ */
public class JsonBoostFieldMapper extends JsonNumberFieldMapper<Float> implements BoostFieldMapper { public class JsonBoostFieldMapper extends JsonNumberFieldMapper<Float> implements BoostFieldMapper {
public static final String JSON_TYPE = "boostField"; public static final String JSON_TYPE = "_boost";
public static class Defaults extends JsonNumberFieldMapper.Defaults { public static class Defaults extends JsonNumberFieldMapper.Defaults {
public static final String NAME = "_boost"; public static final String NAME = "_boost";

View File

@ -120,17 +120,17 @@ public class JsonDocumentMapperParser implements DocumentMapperParser {
String fieldName = entry.getKey(); String fieldName = entry.getKey();
JsonNode fieldNode = entry.getValue(); JsonNode fieldNode = entry.getValue();
if (JsonSourceFieldMapper.JSON_TYPE.equals(fieldName)) { if (JsonSourceFieldMapper.JSON_TYPE.equals(fieldName) || "sourceField".equals(fieldName)) {
docBuilder.sourceField(parseSourceField((ObjectNode) fieldNode, parserContext)); docBuilder.sourceField(parseSourceField((ObjectNode) fieldNode, parserContext));
} else if (JsonIdFieldMapper.JSON_TYPE.equals(fieldName)) { } else if (JsonIdFieldMapper.JSON_TYPE.equals(fieldName) || "idField".equals(fieldName)) {
docBuilder.idField(parseIdField((ObjectNode) fieldNode, parserContext)); docBuilder.idField(parseIdField((ObjectNode) fieldNode, parserContext));
} else if (JsonTypeFieldMapper.JSON_TYPE.equals(fieldName)) { } else if (JsonTypeFieldMapper.JSON_TYPE.equals(fieldName) || "typeField".equals(fieldName)) {
docBuilder.typeField(parseTypeField((ObjectNode) fieldNode, parserContext)); docBuilder.typeField(parseTypeField((ObjectNode) fieldNode, parserContext));
} else if (JsonUidFieldMapper.JSON_TYPE.equals(fieldName)) { } else if (JsonUidFieldMapper.JSON_TYPE.equals(fieldName) || "uidField".equals(fieldName)) {
docBuilder.uidField(parseUidField((ObjectNode) fieldNode, parserContext)); docBuilder.uidField(parseUidField((ObjectNode) fieldNode, parserContext));
} else if (JsonBoostFieldMapper.JSON_TYPE.equals(fieldName)) { } else if (JsonBoostFieldMapper.JSON_TYPE.equals(fieldName) || "boostField".equals(fieldName)) {
docBuilder.boostField(parseBoostField((ObjectNode) fieldNode, parserContext)); docBuilder.boostField(parseBoostField((ObjectNode) fieldNode, parserContext));
} else if (JsonAllFieldMapper.JSON_TYPE.equals(fieldName)) { } else if (JsonAllFieldMapper.JSON_TYPE.equals(fieldName) || "allField".equals(fieldName)) {
docBuilder.allField(parseAllField((ObjectNode) fieldNode, parserContext)); docBuilder.allField(parseAllField((ObjectNode) fieldNode, parserContext));
} else if ("indexAnalyzer".equals(fieldName)) { } else if ("indexAnalyzer".equals(fieldName)) {
docBuilder.indexAnalyzer(analysisService.analyzer(fieldNode.getTextValue())); docBuilder.indexAnalyzer(analysisService.analyzer(fieldNode.getTextValue()));

View File

@ -35,7 +35,7 @@ import java.io.IOException;
*/ */
public class JsonIdFieldMapper extends JsonFieldMapper<String> implements IdFieldMapper { public class JsonIdFieldMapper extends JsonFieldMapper<String> implements IdFieldMapper {
public static final String JSON_TYPE = "idField"; public static final String JSON_TYPE = "_id";
public static class Defaults extends JsonFieldMapper.Defaults { public static class Defaults extends JsonFieldMapper.Defaults {
public static final String NAME = "_id"; public static final String NAME = "_id";
@ -118,7 +118,9 @@ public class JsonIdFieldMapper extends JsonFieldMapper<String> implements IdFiel
} }
@Override public void toJson(JsonBuilder builder, Params params) throws IOException { @Override public void toJson(JsonBuilder builder, Params params) throws IOException {
// for now, don't output it at all builder.startObject(JSON_TYPE);
builder.field("store", store.name().toLowerCase());
builder.endObject();
} }
@Override public void merge(JsonMapper mergeWith, JsonMergeContext mergeContext) throws MergeMappingException { @Override public void merge(JsonMapper mergeWith, JsonMergeContext mergeContext) throws MergeMappingException {

View File

@ -32,7 +32,7 @@ import java.io.IOException;
*/ */
public class JsonSourceFieldMapper extends JsonFieldMapper<byte[]> implements SourceFieldMapper { public class JsonSourceFieldMapper extends JsonFieldMapper<byte[]> implements SourceFieldMapper {
public static final String JSON_TYPE = "sourceField"; public static final String JSON_TYPE = "_source";
public static class Defaults extends JsonFieldMapper.Defaults { public static class Defaults extends JsonFieldMapper.Defaults {
public static final String NAME = SourceFieldMapper.NAME; public static final String NAME = SourceFieldMapper.NAME;

View File

@ -35,7 +35,7 @@ import java.io.IOException;
*/ */
public class JsonTypeFieldMapper extends JsonFieldMapper<String> implements TypeFieldMapper { public class JsonTypeFieldMapper extends JsonFieldMapper<String> implements TypeFieldMapper {
public static final String JSON_TYPE = "typeField"; public static final String JSON_TYPE = "_type";
public static class Defaults extends JsonFieldMapper.Defaults { public static class Defaults extends JsonFieldMapper.Defaults {
public static final String NAME = TypeFieldMapper.NAME; public static final String NAME = TypeFieldMapper.NAME;
@ -107,7 +107,9 @@ public class JsonTypeFieldMapper extends JsonFieldMapper<String> implements Type
} }
@Override public void toJson(JsonBuilder builder, Params params) throws IOException { @Override public void toJson(JsonBuilder builder, Params params) throws IOException {
// for now, don't output it at all builder.startObject(JSON_TYPE);
builder.field("store", store.name().toLowerCase());
builder.endObject();
} }
@Override public void merge(JsonMapper mergeWith, JsonMergeContext mergeContext) throws MergeMappingException { @Override public void merge(JsonMapper mergeWith, JsonMergeContext mergeContext) throws MergeMappingException {

View File

@ -36,7 +36,7 @@ import java.io.IOException;
*/ */
public class JsonUidFieldMapper extends JsonFieldMapper<Uid> implements UidFieldMapper { public class JsonUidFieldMapper extends JsonFieldMapper<Uid> implements UidFieldMapper {
public static final String JSON_TYPE = "uidField"; public static final String JSON_TYPE = "_uid";
public static class Defaults extends JsonFieldMapper.Defaults { public static class Defaults extends JsonFieldMapper.Defaults {
public static final String NAME = UidFieldMapper.NAME; public static final String NAME = UidFieldMapper.NAME;

View File

@ -1,6 +1,6 @@
{ {
person : { person : {
allField : {enabled : true}, _all : {enabled : true},
properties : { properties : {
name : { name : {
type : "object", type : "object",

View File

@ -1,6 +1,6 @@
{ {
person : { person : {
allField : {enabled : true, store : "yes"}, _all : {enabled : true, store : "yes"},
properties : { properties : {
name : { name : {
type : "object", type : "object",

View File

@ -2,10 +2,10 @@
dateFormats : ["yyyy-MM-dd", "dd-MM-yyyy"], dateFormats : ["yyyy-MM-dd", "dd-MM-yyyy"],
dynamic : false, dynamic : false,
enabled : true, enabled : true,
idField : {name : "_id", indexName : "_id"}, _id : {name : "_id", indexName : "_id"},
sourceField : {name : "_source", compressionThreshold : 0}, _source : {name : "_source", compressionThreshold : 0},
typeField : {name : "_type"}, _type : {name : "_type"},
boostField : {name : "_boost", nullValue : 2.0}, _boost : {name : "_boost", nullValue : 2.0},
properties : { properties : {
name : { name : {
type : "object", type : "object",

View File

@ -3,10 +3,10 @@
dateFormats : ["yyyy-MM-dd", "dd-MM-yyyy"], dateFormats : ["yyyy-MM-dd", "dd-MM-yyyy"],
dynamic : false, dynamic : false,
enabled : true, enabled : true,
idField : {name : "_id", indexName : "_id"}, _id : {name : "_id", indexName : "_id"},
sourceField : {name : "_source", compressionThreshold : 0}, _source : {name : "_source"},
typeField : {name : "_type"}, _type : {name : "_type"},
boostField : {name : "_boost", nullValue : 2.0}, _boost : {name : "_boost", nullValue : 2.0},
properties : { properties : {
name : { name : {
type : "object", type : "object",

View File

@ -109,7 +109,7 @@ public class HighlightSearchTests extends AbstractServersTests {
public JsonBuilder mapping() throws IOException { public JsonBuilder mapping() throws IOException {
return binaryJsonBuilder().startObject().startObject("type1") return binaryJsonBuilder().startObject().startObject("type1")
.startObject("allField").field("store", "yes").field("termVector", "with_positions_offsets").endObject() .startObject("_all").field("store", "yes").field("termVector", "with_positions_offsets").endObject()
.endObject().endObject(); .endObject().endObject();
} }