Spring boot 具有IP_范围数据类型的Spring数据弹性搜索问题
我使用Spring boot 2.0.1.RELEASE/Spring Data Elasticsearch 3.0.6。 我用@Document annotation注释我的域类,我有一个字段,如下所示:Spring boot 具有IP_范围数据类型的Spring数据弹性搜索问题,spring-boot,spring-data,
spring-data-elasticsearch,elasticsearch-6,custom-data-type,Spring Boot,Spring Data,
spring Data Elasticsearch,Elasticsearch 6,Custom Data Type,我使用Spring boot 2.0.1.RELEASE/Spring Data Elasticsearch 3.0.6。 我用@Document annotation注释我的域类,我有一个字段,如下所示: @Field(store = true, type = FieldType.?) private String ipRange; 如您所见,我需要将字段类型设置为IP_范围(存在于弹性搜索引擎数据类型中) 但字段类型枚举中不存在 我想通过ElasticsearchTemplate.crea
@Field(store = true, type = FieldType.?)
private String ipRange;
如您所见,我需要将字段类型设置为IP_范围(存在于弹性搜索引擎数据类型中)
但字段类型枚举中不存在
我想通过ElasticsearchTemplate.createIndex(doc)方法创建此文档索引。但是没有任何FieldType枚举支持ip_范围数据类型。Spring data Elasticsearch当前(3.2.0.M2)不支持此功能。我看到你已经打开了一个问题,谢谢你。这里的答案只是为了完整性,也为了其他有同样问题的用户谢谢@p.J.Meisch的回复,我使用@Mapping annotation通过json格式直接指定了我的映射。Spring数据已经支持基于此配置创建索引。但我也在等待重构我的代码 我的文件:
@Document(createIndex = true, indexName = "mydomain", type = "doc-rule"
, refreshInterval = BaseDocument.REFRESH_INTERVAL, replicas = BaseDocument.REPLICA_COUNT, shards = BaseDocument.SHARD_COUNT)
@Mapping(mappingPath = "/elasticsearch/mappings/mydomain-mapping.json")
public class MyDomainDoc {
@Field(store = true, type = FieldType.text)
private List<String> ipRange;
... other fields
}
{
"properties": {
...,
"ipRange": {
"type": "ip_range",
...
},
...
}
}