使用多种映射类型进行索引
Indexing with multiple mapping types
我有这个映射文件:
{
"type1": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
}
},
"type2": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
我的 类 使用此映射:
@Document(indexName = "cake", type = "type1")
@Mapping(mappingPath = "/elasticsearch/config/mappings.json")
public class TypeOneElasticEntity implements Serializable {
}
@Document(indexName = "cake", type = "type2")
@Mapping(mappingPath = "/elasticsearch/config/mappings.json")
public class TypeTwoElasticEntity implements Serializable {
}
问题是当我想索引 TypeTwoElasticEntity
时,我得到这个错误:
根映射定义有不支持的参数"type1"
所以我想我必须使用第二个文件。但是在这种情况下是否可以将多种类型放在一个文件中?
谢谢!
不,一个 index type
有一个映射。但是,index types
将不再受支持并将被弃用。如果您有多个映射,则需要为每个创建一个 单独的索引 。
我有这个映射文件:
{
"type1": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
}
},
"type2": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
我的 类 使用此映射:
@Document(indexName = "cake", type = "type1")
@Mapping(mappingPath = "/elasticsearch/config/mappings.json")
public class TypeOneElasticEntity implements Serializable {
}
@Document(indexName = "cake", type = "type2")
@Mapping(mappingPath = "/elasticsearch/config/mappings.json")
public class TypeTwoElasticEntity implements Serializable {
}
问题是当我想索引 TypeTwoElasticEntity
时,我得到这个错误:
根映射定义有不支持的参数"type1"
所以我想我必须使用第二个文件。但是在这种情况下是否可以将多种类型放在一个文件中?
谢谢!
不,一个 index type
有一个映射。但是,index types
将不再受支持并将被弃用。如果您有多个映射,则需要为每个创建一个 单独的索引 。