Mapper: Rename allFIeld to _all, sourceField to _source, idField to _id, and typeField to _type, closes #105.
This commit is contained in:
parent
5da4b0748f
commit
6bf19fcd93
|
@ -42,7 +42,7 @@ import static org.elasticsearch.util.lucene.all.AllTokenFilter.*;
|
|||
*/
|
||||
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 final String NAME = AllFieldMapper.NAME;
|
||||
|
|
|
@ -38,7 +38,7 @@ import java.io.IOException;
|
|||
*/
|
||||
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 final String NAME = "_boost";
|
||||
|
|
|
@ -120,17 +120,17 @@ public class JsonDocumentMapperParser implements DocumentMapperParser {
|
|||
String fieldName = entry.getKey();
|
||||
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));
|
||||
} else if (JsonIdFieldMapper.JSON_TYPE.equals(fieldName)) {
|
||||
} else if (JsonIdFieldMapper.JSON_TYPE.equals(fieldName) || "idField".equals(fieldName)) {
|
||||
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));
|
||||
} else if (JsonUidFieldMapper.JSON_TYPE.equals(fieldName)) {
|
||||
} else if (JsonUidFieldMapper.JSON_TYPE.equals(fieldName) || "uidField".equals(fieldName)) {
|
||||
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));
|
||||
} else if (JsonAllFieldMapper.JSON_TYPE.equals(fieldName)) {
|
||||
} else if (JsonAllFieldMapper.JSON_TYPE.equals(fieldName) || "allField".equals(fieldName)) {
|
||||
docBuilder.allField(parseAllField((ObjectNode) fieldNode, parserContext));
|
||||
} else if ("indexAnalyzer".equals(fieldName)) {
|
||||
docBuilder.indexAnalyzer(analysisService.analyzer(fieldNode.getTextValue()));
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.io.IOException;
|
|||
*/
|
||||
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 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 {
|
||||
// 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 {
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.io.IOException;
|
|||
*/
|
||||
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 final String NAME = SourceFieldMapper.NAME;
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.io.IOException;
|
|||
*/
|
||||
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 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 {
|
||||
// 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 {
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.io.IOException;
|
|||
*/
|
||||
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 final String NAME = UidFieldMapper.NAME;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
person : {
|
||||
allField : {enabled : true},
|
||||
_all : {enabled : true},
|
||||
properties : {
|
||||
name : {
|
||||
type : "object",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
person : {
|
||||
allField : {enabled : true, store : "yes"},
|
||||
_all : {enabled : true, store : "yes"},
|
||||
properties : {
|
||||
name : {
|
||||
type : "object",
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
dateFormats : ["yyyy-MM-dd", "dd-MM-yyyy"],
|
||||
dynamic : false,
|
||||
enabled : true,
|
||||
idField : {name : "_id", indexName : "_id"},
|
||||
sourceField : {name : "_source", compressionThreshold : 0},
|
||||
typeField : {name : "_type"},
|
||||
boostField : {name : "_boost", nullValue : 2.0},
|
||||
_id : {name : "_id", indexName : "_id"},
|
||||
_source : {name : "_source", compressionThreshold : 0},
|
||||
_type : {name : "_type"},
|
||||
_boost : {name : "_boost", nullValue : 2.0},
|
||||
properties : {
|
||||
name : {
|
||||
type : "object",
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
dateFormats : ["yyyy-MM-dd", "dd-MM-yyyy"],
|
||||
dynamic : false,
|
||||
enabled : true,
|
||||
idField : {name : "_id", indexName : "_id"},
|
||||
sourceField : {name : "_source", compressionThreshold : 0},
|
||||
typeField : {name : "_type"},
|
||||
boostField : {name : "_boost", nullValue : 2.0},
|
||||
_id : {name : "_id", indexName : "_id"},
|
||||
_source : {name : "_source"},
|
||||
_type : {name : "_type"},
|
||||
_boost : {name : "_boost", nullValue : 2.0},
|
||||
properties : {
|
||||
name : {
|
||||
type : "object",
|
||||
|
|
|
@ -109,7 +109,7 @@ public class HighlightSearchTests extends AbstractServersTests {
|
|||
|
||||
public JsonBuilder mapping() throws IOException {
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue