0

I want to use the elastic4s api to delete and create templates. I couldn't find an api to create a template with a given content, only create by providing a name.
Not sure how to use the IndexTemplateDsl.

Is this the right direction?

Tomer
  • 2,398
  • 1
  • 23
  • 31

1 Answers1

0

You create the template with a name, and then specifying the pattern match for that template, then you can add your mappings.

  val req = create template "my_template" pattern "matchme.*" mappings(
    mapping("sometype1").fields(
      stringField("field1"),
      geopointField("field2")
    ),
    mapping("sometype2").fields(
      stringField("field3"),
      intField("field4")
    )
  )
client.execute(req)

So it's very similar to creating a normal index.

sksamuel
  • 16,154
  • 8
  • 60
  • 108