Elastic Search - how to create index with mapping

elasticsearch:8.7.1

I am creating index this way:


return new CreateIndexRequest.Builder()
                 .index(name)
                 .aliases(alias, new Alias.Builder().build())
                 .settings(new IndexSettings.Builder()
                         .numberOfShards(String.valueOf(shardsAmount))
                         .build())
                 .build();

I want add mapping like this:

 return new CreateIndexRequest.Builder()
                  .index(name)
                  .mappings(
                      new TypeMapping.Builder()...

and I have no idea what next.
Can any one share example or link where I can find it?

May be this could help?

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