# Create index pattern with python

**URL:** <https://discuss.elastic.co/t/create-index-pattern-with-python/242633>\
**Category:** Elasticsearch\
**Created:** [July 26, 2020, 7:22am UTC](https://discuss.elastic.co/t/create-index-pattern-with-python/242633 "2020-07-26T07:22:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![momora9809](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@momora9809](https://discuss.elastic.co/u/momora9809)\
**Post date:** [July 26, 2020, 7:22am UTC](https://discuss.elastic.co/t/create-index-pattern-with-python/242633/1 "2020-07-26T07:22:14Z")

</div>

Hi,  
How can I set index pattern with python, before putting any docs?  
I came up with this, am I on the right tracks?

```auto
query = 
"settings": {
        "number_of_shards": 2,
        "number_of_replicas": 1,
        "mappings": {...},
        "index-pattern" : {
            "title" : "myindex",
            "timeFieldName" : "sendTime",
            "fields" : """[{"name":"_id","type":"string","esTypes":["_id"],"count":0, ...]}"""

es_client.indices.create(index = "myindex" , body = query)

```

Am I missing sth?

---

<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:** [August 23, 2020, 7:22am UTC](https://discuss.elastic.co/t/create-index-pattern-with-python/242633/2 "2020-08-23T07:22:19Z")

</div>

Closed on August 23, 2020, 7:22am UTC

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