# Use elasticsearch-py client to search, and get index\_not\_found\_exception error, why?

**URL:** <https://discuss.elastic.co/t/use-elasticsearch-py-client-to-search-and-get-index-not-found-exception-error-why/70322>\
**Category:** Elasticsearch\
**Created:** [January 1, 2017, 4:35am UTC](https://discuss.elastic.co/t/use-elasticsearch-py-client-to-search-and-get-index-not-found-exception-error-why/70322 "2017-01-01T04:35:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mover](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mover](https://discuss.elastic.co/u/mover)\
**Post date:** [January 1, 2017, 4:35am UTC](https://discuss.elastic.co/t/use-elasticsearch-py-client-to-search-and-get-index-not-found-exception-error-why/70322/1 "2017-01-01T04:35:13Z")

</div>

i use elasticsearch-py client to do search, but get the follow error:

Traceback (most recent call last):  
File "./netflow\_ana\_ra\_ip\_hn.py", line 203, in   
main()  
File "./netflow\_ana\_ra\_ip\_hn.py", line 185, in main  
search\_index\_and\_dump(each\_index, direction, topn, who)  
File "./netflow\_ana\_ra\_ip\_hn.py", line 137, in search\_index\_and\_dump  
(sum\_bytes, buckets\_dict) = search\_unit(each\_index, direction, topn, who, prefer)  
File "./netflow\_ana\_ra\_ip\_hn.py", line 41, in search\_unit  
result = es.search(search\_parameters)  
File "/root/.jumbo/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 71, in \_wrapped  
return func(\*args, params=params, \*\*kwargs)  
File "/root/.jumbo/lib/python2.7/site-packages/elasticsearch/client/ **init**.py", line 569, in search  
doc\_type, '\_search'), params=params, body=body)  
File "/root/.jumbo/lib/python2.7/site-packages/elasticsearch/transport.py", line 327, in perform\_request  
status, headers, data = connection.perform\_request(method, url, params, body, ignore=ignore, timeout=timeout)  
File "/root/.jumbo/lib/python2.7/site-packages/elasticsearch/connection/http\_urllib3.py", line 124, in perform\_request  
self.\_raise\_error(response.status, raw\_data)  
File "/root/.jumbo/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 122, in \_raise\_error  
raise HTTP\_EXCEPTIONS.get(status\_code, TransportError)(status\_code, error\_message, additional\_info)  
elasticsearch.exceptions.NotFoundError: TransportError(404, u'index\_not\_found\_exception', u'no such index')

============  
the python code :  
search\_parameters = {}  
search\_parameters['index'] = 'netflow\_log-2016.12.01'  
search\_parameters['body'] = get\_query\_string(direction, topn, who)  
search\_parameters['\_source'] = False  
search\_parameters['preference'] = prefer  
search\_parameters['search\_type'] = 'query\_then\_fetch'  
search\_parameters['size'] = 0

```
es = Elasticsearch(['localhost:8200'])
result = es.search(search_parameters)

```

I am sure the elasticsearch has the index 'netflow\_log-2016.12.01', and  
the get\_query\_string(direction, topn, who) funtion is correct also.

Can somebody tell me what wrong is there?  
thanks very much!

---

<div class="post-metadata">

**Author:** ![mover](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mover](https://discuss.elastic.co/u/mover)\
**Post date:** [January 1, 2017, 6:35am UTC](https://discuss.elastic.co/t/use-elasticsearch-py-client-to-search-and-get-index-not-found-exception-error-why/70322/2 "2017-01-01T06:35:55Z")

</div>

en, i have corrected the error.

this code line should be modified from  
result = es.search(search\_parameters)  
to  
result = es.search(\*\*search\_parameters)

---

<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:** [January 29, 2017, 6:35am UTC](https://discuss.elastic.co/t/use-elasticsearch-py-client-to-search-and-get-index-not-found-exception-error-why/70322/3 "2017-01-29T06:35:57Z")

</div>

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