# ES Search tutorial :: 'no such index \[my\_documents\]',

**URL:** <https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538>\
**Category:** Elasticsearch\
**Created:** [April 26, 2025, 2:07am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538 "2025-04-26T02:07:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![A\_ai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_ai/32/140966_2.png) [@A\_ai](https://discuss.elastic.co/u/A_ai)\
**Post date:** [April 26, 2025, 2:07am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/1 "2025-04-26T02:07:45Z")

</div>

Hi  
Total noob to ES. I am doing the Search tutorial here: [Search Basics - Elasticsearch Labs](https://www.elastic.co/search-labs/tutorials/search-tutorial/full-text-search/search-basics)

So far so good, but when I run the sample search term 'policy', it gives me a  
elasticsearch.NotFoundError: NotFoundError(404, 'index\_not\_found\_exception', 'no such index [my\_documents]', my\_documents, index\_or\_alias)

What am i doing wrong? Thanks

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 26, 2025, 3:50am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/2 "2025-04-26T03:50:49Z")

</div>

Did you follow the [Create an Elasticsearch Index](https://www.elastic.co/search-labs/tutorials/search-tutorial/full-text-search/create-index) step in the guide that creates the data you will search?

---

<div class="post-metadata">

**Author:** ![A\_ai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_ai/32/140966_2.png) [@A\_ai](https://discuss.elastic.co/u/A_ai)\
**Post date:** [April 26, 2025, 4:40am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/3 "2025-04-26T04:40:48Z")

</div>

Hi @Christian_Dahlqvist - Yes. And thanks for responding. I've simply followed the tutorial direction. I'm sure this is a rtfm moment for me.. Here's my search.py

```auto
import json
from pprint import pprint
import os
import time

from dotenv import load_dotenv
from elasticsearch import Elasticsearch

load_dotenv()
class Search:
    def __init__ (self):
        self.es = Elasticsearch(cloud_id=os.environ['ELASTIC_CLOUD_ID'],
                                api_key=os.environ['ELASTIC_API_KEY'])
        # ...
        client_info = self.es.info()
        print(' *****eyeball*****')
        pprint(client_info.body)

    def create_index(self):
        self.es.indices.delete(index='my_documents', ignore_unavailable=True)
        self.es.indices.create(index='my_documents')

    def insert_document(self, document):
        return self.es.index(index='my_documents', body=document)

    def insert_documents(self, documents):
        operations = []
        for document in documents:
            operations.append({'index': {'_index': 'my_documents'}})
            operations.append(document)
        return self.es.bulk(operations=operations)

    def search(self, **query_args):
        return self.es.search(index='my_documents', **query_args)

```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 26, 2025, 4:46am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/4 "2025-04-26T04:46:11Z")

</div>

Did you create the index and add some documents before trying to run a search?

---

<div class="post-metadata">

**Author:** ![A\_ai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_ai/32/140966_2.png) [@A\_ai](https://discuss.elastic.co/u/A_ai)\
**Post date:** [April 26, 2025, 5:21am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/5 "2025-04-26T05:21:38Z")

</div>

Where's the instructions to add those documents? Truly an RTFM moment for me perhaps. Isn't that in the json file?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 26, 2025, 6:21am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/6 "2025-04-26T06:21:51Z")

</div>

I have not gone used this tutorial, but the docs I linked to contains an example of how to load data from the data.json file. This should apparently be part of the project you downloaded [here](https://www.elastic.co/search-labs/tutorials/search-tutorial/starter-project). Seems like you have missed adding the data.

---

<div class="post-metadata">

**Author:** ![A\_ai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_ai/32/140966_2.png) [@A\_ai](https://discuss.elastic.co/u/A_ai)\
**Post date:** [April 26, 2025, 6:53am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/7 "2025-04-26T06:53:05Z")

</div>

Yeap. All that is downloaded. My folder structure is exactly as shown there. I'm following the tutorial to the 'tee'. What am I missing.

This is the running log from my flask

```auto

/search-tutorial/.venv/lib/python3.9/site-packages/elasticsearch/_sync/client/_base.py", line 351, in _perform_request

raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(

elasticsearch.NotFoundError: NotFoundError(404, 'index_not_found_exception', 'no such index [my_documents]', my_documents, index_or_alias)

127.0.0.1 - - [25/Apr/2025 21:42:12] "GET /? __debugger__ =yes&cmd=resource&f=style.css HTTP/1.1" 304 -

127.0.0.1 - - [25/Apr/2025 21:42:12] "GET /? __debugger__ =yes&cmd=resource&f=debugger.js HTTP/1.1" 304 -

127.0.0.1 - - [25/Apr/2025 21:42:12] "GET /? __debugger__ =yes&cmd=resource&f=console.png HTTP/1.1" 304 -

127.0.0.1 - - [25/Apr/2025 21:42:12] "GET /? __debugger__ =yes&cmd=resource&f=console.png HTTP/1.1" 304 -
```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 26, 2025, 6:55am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/8 "2025-04-26T06:55:33Z")

</div>

Have you run this section before searching?

```auto
import json
from search import Search
es = Search()
with open('data.json', 'rt') as f:
    documents = json.loads(f.read())
for document in documents:
    es.insert_document(document)

```

---

<div class="post-metadata">

**Author:** ![A\_ai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_ai/32/140966_2.png) [@A\_ai](https://discuss.elastic.co/u/A_ai)\
**Post date:** [April 26, 2025, 7:07am UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/9 "2025-04-26T07:07:06Z")

</div>

Where is this listed in the tutorial documentation? THank you.

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [April 26, 2025, 6:07pm UTC](https://discuss.elastic.co/t/es-search-tutorial-no-such-index-my-documents/377538/10 "2025-04-26T18:07:17Z")

</div>

> [@A\_ai](#):
>
> Where is this listed in the tutorial documentation

The link you shared was:

> **[Search Basics - Elasticsearch Labs](https://www.elastic.co/search-labs/tutorials/search-tutorial/full-text-search/search-basics)**
>
> Follow this Elasticsearch tutorial to learn how to create a complete search solution. We’ll cover the requirements and implementation details.

The section in the tutorial directly before "Search basics" is called "Create an Index", and has URL

> **[Create an Elasticsearch Index - Elasticsearch Labs](https://www.elastic.co/search-labs/tutorials/search-tutorial/full-text-search/create-index)**
>
> Follow this Elasticsearch tutorial to learn how to create a complete search solution. We’ll cover the requirements and implementation details.

The code @Christian_Dahlqvist quoted is taken directly from that URL, and the specific code snippet is preceded by:

> To import the entire contents of the **data.json** file, you _could_ do something like this

That _could_ leaves some wiggle room, I guess. Anyways, the tutorial runs through a few other things and ends with

> Now when you want to generate a clean index, all you need to do is run flask reindex.

Again, giving benefit of the doubt, it doesn't say you **must** do a `flask reindex` at that point either.

I think the mindset is that at this point in the tutorial you will have understood that Elasticsearch is (at one level) based around searching index-es, and index-es contain documents.

There's a link at the bottom, click Report an issue, which you can use to send feedback about the tutorial.

As someone who has written many of these sort of tutorials/cookbooks/step-by-step guides, almost all feedback is appreciated as the authors tend to start from a different place compared to the readers, and know that they do, and can't always appreciate how their text will actually be understood/interpreted by others with different levels of knowledge/understanding.
