Some questions about PutComponentTemplateRequest in Java API

When i use the Elasticsearch of version 7.17.2, i found something when i use the PutComponentTemplateRequest.
i used 7.11.1 in my last project, so i refer the guide document and follow it to create :

PutComponentTemplateRequest request = new PutComponentTemplateRequest()

Settings settings = Settings.builder()
    .put("index.number_of_shards", 3)
    .put("index.number_of_replicas", 1)
String mappingJson = "{\n" +
    "  \"properties\": {\n" +
    "    \"message\": {\n" +
    "      \"type\": \"text\"\n" +
    "    }\n" +
    "  }\n" +
AliasMetadata twitterAlias = AliasMetadata.builder("twitter_alias").build();
Map<String, AliasMetadata> aliases = new HashMap<>();
aliases.put("twitter_alias", twitterAlias);
Template template = new Template(settings, new CompressedXContent(mappingJson), aliases); 

request.componentTemplate(new ComponentTemplate(template, null, null));
assertTrue(client.cluster().putComponentTemplate(request, RequestOptions.DEFAULT).isAcknowledged());

this way is easy for me, when i need add something else , i can just edit the string and redeploy it.

but when i use the elasticsearch of 7.17.2, i can not found any guide documentation to know how to use it.
i read the source code and i found this way also can create a PutComponentTemplateRequest :

PutComponentTemplateRequest request = PutComponentTemplateRequest.of(b -> {

  IndexSettingsAnalysis analysis = IndexSettingsAnalysis.of(analysisBuilder -> {
	  Analyzer analyzer = Analyzer.of(analyzerBuilder -> {
		 return analyzerBuilder.custom(CustomAnalyzer.of(customAnalyzerBuilder -> {
			  return customAnalyzerBuilder.filter("icu_folding", "word_delimiter_graph")
					  .charFilter("icu_normalizer", "html_strip")
	 return analysisBuilder.analyzer("custom_text_analyzer", analyzer);
  IndexSettings settings = IndexSettings.of(indexBuild -> {
	  return indexBuild.numberOfShards("2").numberOfReplicas("1").maxResultWindow(100000)

  return b.settings(settings);

but when i want to add the mapping or something else, isn't easier. i always need to use the Builder or the Lambda to add something. but i really want just edit the JSON String so i can really know what's i added and i can check template source.
so guys,do u have any good idea about create a new PutComponentTemplateRequest?
sorry for my terriable English and Tech, and thank you for listening.

guys! helppppppp!!!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.