# How to create Template for an index using Java API?

**URL:** <https://discuss.elastic.co/t/how-to-create-template-for-an-index-using-java-api/25480>\
**Category:** Elasticsearch\
**Created:** [July 13, 2015, 8:11pm UTC](https://discuss.elastic.co/t/how-to-create-template-for-an-index-using-java-api/25480 "2015-07-13T20:11:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![apanimesh061](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apanimesh061/32/927_2.png) [@apanimesh061](https://discuss.elastic.co/u/apanimesh061)\
**Post date:** [July 13, 2015, 8:11pm UTC](https://discuss.elastic.co/t/how-to-create-template-for-an-index-using-java-api/25480/1 "2015-07-13T20:11:45Z")

</div>

```
PUT /_template/some_template
{
  "template": "some_*",
  "settings": {
    "index.store.type": "default",
    "index": {
      "number_of_shards": 5,
      "number_of_replicas": 1,
      "refresh_interval": "60s"
    },
    "analysis": {
      "filter": {
        "porter_stemmer_en_EN": {
          "type": "stemmer",
          "name": "porter"
        }
      }
    }
  },
  "mappings": {
    "_default_": {
      "dynamic": "strict",
      "properties": {
        "docset_id": {
          "include_in_all": false,
          "type": "string",
          "index": "not_analyzed"
        },
        "doc_id": {
          "include_in_all": false,
          "type": "string",
          "index": "not_analyzed"
        },
        "plain_text": {
          "type": "string",
          "store": true
        }
      }
    }
  }
}

```

I have this template. How should I use this in Java API ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:01am UTC](https://discuss.elastic.co/t/how-to-create-template-for-an-index-using-java-api/25480/2 "2017-07-06T00:01:45Z")

</div>


