0
votes

I use Spring boot 2.0.1.RELEASE/ Spring Data Elasticsearch 3.0.6. I annotate my domain class with @Document annotation and i have a field as below:

@Field(store = true, type = FieldType.?)
private String ipRange;

as you see, I need to set the field type to IP_Range (exists in elastic search engine data types) but not exists in FieldType enum.

I want to create this document index by ElasticsearchTemplate.createIndex(doc) method. but none of any FieldType enum support ip_range data type.

2

2 Answers

1
votes

Spring Data Elasticsearch currently (3.2.0.M2) does not support this. I saw that you already opened an issue, thanks for that. The answer here is just for the completeness and for other users having the same problem

0
votes

Thanks @P.J.Meisch for your reply, I used @Mapping annotation to specify my mapping directly via json format. Already Spring data supports creating index based on this config. but i am also waiting for Range Data Structure Support to refactor my code.

My Document:

@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

}

And My mydomain-mapping.json file:

{
  "properties": {
    ...,
    "ipRange": {
      "type": "ip_range",
      ...
    },
    ...
  }
}