When I used curl to create my template, it works fine. But when I used High Level REST it gave me the exception:
org.elasticsearch.ElasticsearchException: Elasticsearch exception [type=mapper_parsing_exception, reason=Root mapping definition has unsupported parameters: [document : {properties={cx_date={index=false, type=date}, doi_derived_from_publication={type=text}, publishing_poc={type=text}, sources={type=text}, cat_id={type=keyword}, title={type=text, fields={keyword={type=keyword}}}, coverages={type=text}, content={type=text}, DOI_end={type=date}, original_filename={type=text}, title_classification={type=text}, source_numbers={type=text}, summary={type=text}, requirements={type=text}, types={type=keyword}, identifiers={type=text}, topics={type=text}, cat_processed={type=date}, serial_number={type=text}, published={type=date}, classification={type=keyword}, url={type=text, fields={keyword={type=keyword}}}, publishing_organization={type=keyword}, cx={index=false, type=text}, special_instruction={type=text}, DOI_start={type=date}, contains_attachments={type=text}, cat_source={type=keyword}}}]]
at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:509) ~[elasticsearch-6.8.3.jar!/:6.8.3]
at org.elasticsearch.ElasticsearchException.fromXContent(ElasticsearchException.java:420) ~[elasticsearch-6.8.3.jar!/:6.8.3]
at org.elasticsearch.ElasticsearchException.innerFromXContent(ElasticsearchException.java:450) ~[elasticsearch-6.8.3.jar!/:6.8.3]
at org.elasticsearch.ElasticsearchException.failureFromXContent(ElasticsearchException.java:616) ~[elasticsearch-6.8.3.jar!/:6.8.3]
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:169) ~[elasticsearch-6.8.3.jar!/:6.8.3]
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:2053) ~[elasticsearch-rest-high-level-client-6.8.3.jar!/:6.8.3]
at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:2030) ~[elasticsearch-rest-high-level-client-6.8.3.jar!/:6.8.3]
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1777) ~[elasticsearch-rest-high-level-client-6.8.3.jar!/:6.8.3]
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1734) ~[elasticsearch-rest-high-level-client-6.8.3.jar!/:6.8.3]
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1696) ~[elasticsearch-rest-high-level-client-6.8.3.jar!/:6.8.3]
at org.elasticsearch.client.IndicesClient.putTemplate(IndicesClient.java:1539) ~[elasticsearch-rest-high-level-client-6.8.3.jar!/:6.8.3]
...
curl -s -H 'Content-Type: application/json' -X PUT 'http://<elasticsearch>:9200/_template/<templateName>' -d @templates/documentTemplate.json
try {
PutIndexTemplateRequest request = new PutIndexTemplateRequest(<templateName>);
request.source(documentTemplateJsonAsString, XContentType.JSON);
client.indices().putTemplate(request, RequestOptions.DEFAULT).isAcknowledge())
} catch (final IOException e) {
...
}
{
"order": 0,
"version": 2,
"index_patterns": [
"documents_*"
],
"settings": {
"codec": "best_compression",
"index": {
"unassigned": {
"node_left": {
"delayed_timeout": "10m"
}
},
"number_of_shards": "5",
"number_of_replicas": "1",
"blocks": {
"read_only_allow_delete": "false"
}
}
},
"mappings": {
"document": {
"properties": {...}
}
}
Elasticsearch version: 6.8.7
Thank you for your help!