# Opensearch stored indices and documents are lost after restarting the opensearch server

**URL:** <https://forum.opensearch.org/t/opensearch-stored-indices-and-documents-are-lost-after-restarting-the-opensearch-server/10136>\
**Category:** OpenSearch\
**Created:** [June 30, 2022, 10:19am UTC](https://forum.opensearch.org/t/opensearch-stored-indices-and-documents-are-lost-after-restarting-the-opensearch-server/10136 "2022-06-30T10:19:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavindu](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/kavindu/32/3509_2.png) [@kavindu](https://forum.opensearch.org/u/kavindu)\
**Post date:** [June 30, 2022, 10:19am UTC](https://forum.opensearch.org/t/opensearch-stored-indices-and-documents-are-lost-after-restarting-the-opensearch-server/10136/1 "2022-06-30T10:19:50Z")

</div>

I’m using Opensearch 1.0.0 on Docker. I’m using python client for opensearch. As in the documentation for python client, I’m running the following code block

```auto

from opensearchpy import OpenSearch

host = 'localhost'
port = 9200
auth = ('admin', 'admin')

client = OpenSearch(
    hosts = [{'host': host, 'port': port}],
    http_compress = True, # enables gzip compression for request bodies
    http_auth = auth,
    # client_cert = client_cert_path,
    # client_key = client_key_path,
    use_ssl = True,
    verify_certs = False,
    ssl_assert_hostname = False,
    ssl_show_warn = False
)

index_name = 'python-test-index'
index_body = {
  'settings': {
    'index': {
      'number_of_shards': 4
    }
  }
}

response = client.indices.create(index_name, body=index_body)
print('\nCreating index:')
print(response)

```

When I run this for the first time, It runs fine. And gives the following output.

```auto
Creating index:
{'acknowledged': True, 'shards_acknowledged': True, 'index': 'python-test-index'}

```

And if I tries to run it more then once, It throws a error indication that the index is already there. That is what I expected.

But If I ran the same block after stopping the docker container and restarting it, It creates the index again, Which means the existing index and data has gone after restarting the container.

How to create a permanent index in opensearch via python client?

Thank you

---

<div class="post-metadata">

**Author:** ![divyank\_1](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@divyank\_1](https://forum.opensearch.org/u/divyank_1)\
**Post date:** [July 1, 2022, 5:18am UTC](https://forum.opensearch.org/t/opensearch-stored-indices-and-documents-are-lost-after-restarting-the-opensearch-server/10136/2 "2022-07-01T05:18:14Z")

</div>

Hi ,

I am also using opensearch, python client for pushing data to index.  
It works fine for me.

My Opensearch version -2.0.0, use docker-compose.yml from site.

> **[Opensearch 2.2.1](https://opensearch.org/downloads.html#opensearch)**
>
> OpenSearch is a community-driven, Apache 2.0-licensed open source search and analytics suite that makes it easy to ingest, search, visualize, and analyze data.

Docker-Desktop Version- 4.8.0  
OS -Windows 10
