# Better error message for missing index

**URL:** <https://discuss.elastic.co/t/better-error-message-for-missing-index/3137>\
**Category:** Elasticsearch\
**Created:** [July 22, 2010, 12:57pm UTC](https://discuss.elastic.co/t/better-error-message-for-missing-index/3137 "2010-07-22T12:57:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alberto\_Paro\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alberto_paro_2/32/1137_2.png) [@Alberto\_Paro\_2](https://discuss.elastic.co/u/Alberto_Paro_2)\
**Post date:** [July 22, 2010, 12:57pm UTC](https://discuss.elastic.co/t/better-error-message-for-missing-index/3137/1 "2010-07-22T12:57:23Z")

</div>

If I try to search in a missing index, ES does return a query message error not very easy to understand.

An exception such as InvalidIndex or MissingIndex should be better.

I'll attach a simple use case (created index myapp\_entry and searched myapp\_blog) with the return message:

curl -XDELETE [http://localhost:9200/test\_test](http://localhost:9200/test_test) -d ''  
curl -XPUT [http://localhost:9200/test\_test/myapp\_entry/4c482e22142bb51d32000001](http://localhost:9200/test_test/myapp_entry/4c482e22142bb51d32000001) -d '{"content": "", "date\_published": "2010-07-22T06:40:18", "blog\_id": null, "id": "4c482e22142bb51d32000001", "title": "entry 1"}'  
curl -XPUT [http://localhost:9200/test\_test/myapp\_entry/4c482e22142bb51d32000002](http://localhost:9200/test_test/myapp_entry/4c482e22142bb51d32000002) -d '{"content": "", "date\_published": "2010-07-23T06:40:18", "blog\_id": null, "id": "4c482e22142bb51d32000002", "title": "entry 2"}'  
curl -XPUT [http://localhost:9200/test\_test/myapp\_entry/4c482e22142bb51d32000003](http://localhost:9200/test_test/myapp_entry/4c482e22142bb51d32000003) -d '{"content": "", "date\_published": "2010-07-21T06:40:18", "blog\_id": null, "id": "4c482e22142bb51d32000003", "title": "entry 3"}'  
curl -XPOST [http://localhost:9200/test\_test/\_refresh](http://localhost:9200/test_test/_refresh)  
curl -XGET '[http://localhost:9200/test\_test/myapp\_blog/\_search](http://localhost:9200/test_test/myapp_blog/_search)' -d '{"query": {"term": {"date\_published" : "2010-07-21T06:40:18"}}}'

Error Message:

{"error":"SearchPhaseExecutionException[Failed to execute [query] total failure; shardFailures {[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][0]: QueryPhaseExecutionException[[test\_test][0]: query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]: Query Failed []]; nested: }{[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][1]: QueryPhaseExecutionException[[test\_test][1]: query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]: Query Failed []]; nested: }{[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][3]: QueryPhaseExecutionException[[test\_test][3]: query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]: Query Failed []]; nested: }{[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][4]: QueryPhaseExecutionException[[test\_test][4]: query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]: Query Failed []]; nested: }{[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][2]: QueryPhaseExecutionException[[test\_test][2]: query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]: Query Failed []]; nested: }]"}

Stacktrace of es:

[14:55:38,875][DEBUG][action.search.type] [Heart Attack] [test\_test][3], node[b59ce67f-7423-4c34-a966-6bfefc1f2294], [P], s[STARTED]: Failed to execute [org.elasticsearch.action.search.SearchRequest@4d88e490]  
org.elasticsearch.search.query.QueryPhaseExecutionException: [test\_test][3]: query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]: Query Failed [Failed to execute main query]  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:124)  
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:169)  
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:129)  
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:77)  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:194)  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$000(TransportSearchTypeAction.java:80)  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.run(TransportSearchTypeAction.java:153)  
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:637)  
Caused by: java.lang.NullPointerException  
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:81)  
... 9 more

Hi,  
Alberto

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 22, 2010, 6:17pm UTC](https://discuss.elastic.co/t/better-error-message-for-missing-index/3137/2 "2010-07-22T18:17:37Z")

</div>

Fixed, and based on your example (and the stack trace) I guess you mean  
searching on an invalid type, not index.

On Thu, Jul 22, 2010 at 3:57 PM, Alberto Paro [alberto.paro@gmail.com](mailto:alberto.paro@gmail.com)wrote:

> If I try to search in a missing index, ES does return a query message error  
> not very easy to understand.
> 
> An exception such as InvalidIndex or MissingIndex should be better.
> 
> I'll attach a simple use case (created index myapp\_entry and searched  
> myapp\_blog) with the return message:
> 
> curl -XDELETE [http://localhost:9200/test\_test](http://localhost:9200/test_test) -d ''  
> curl -XPUT  
> [http://localhost:9200/test\_test/myapp\_entry/4c482e22142bb51d32000001](http://localhost:9200/test_test/myapp_entry/4c482e22142bb51d32000001) -d  
> '{"content": "", "date\_published": "2010-07-22T06:40:18", "blog\_id": null,  
> "id": "4c482e22142bb51d32000001", "title": "entry 1"}'  
> curl -XPUT  
> [http://localhost:9200/test\_test/myapp\_entry/4c482e22142bb51d32000002](http://localhost:9200/test_test/myapp_entry/4c482e22142bb51d32000002) -d  
> '{"content": "", "date\_published": "2010-07-23T06:40:18", "blog\_id": null,  
> "id": "4c482e22142bb51d32000002", "title": "entry 2"}'  
> curl -XPUT  
> [http://localhost:9200/test\_test/myapp\_entry/4c482e22142bb51d32000003](http://localhost:9200/test_test/myapp_entry/4c482e22142bb51d32000003) -d  
> '{"content": "", "date\_published": "2010-07-21T06:40:18", "blog\_id": null,  
> "id": "4c482e22142bb51d32000003", "title": "entry 3"}'  
> curl -XPOST [http://localhost:9200/test\_test/\_refresh](http://localhost:9200/test_test/_refresh)  
> curl -XGET '[http://localhost:9200/test\_test/myapp\_blog/\_search](http://localhost:9200/test_test/myapp_blog/_search)' -d  
> '{"query": {"term": {"date\_published" : "2010-07-21T06:40:18"}}}'
> 
> Error Message:
> 
> {"error":"SearchPhaseExecutionException[Failed to execute [query] total  
> failure; shardFailures  
> {[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][0]:  
> QueryPhaseExecutionException[[test\_test][0]:  
> query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]:  
> Query Failed ]; nested:  
> }{[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][1]:  
> QueryPhaseExecutionException[[test\_test][1]:  
> query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]:  
> Query Failed ]; nested:  
> }{[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][3]:  
> QueryPhaseExecutionException[[test\_test][3]:  
> query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]:  
> Query Failed ]; nested:  
> }{[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][4]:  
> QueryPhaseExecutionException[[test\_test][4]:  
> query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]:  
> Query Failed ]; nested:  
> }{[5183d782-f178-444a-b3d0-a6f31c32be3e][test\_test][2]:  
> QueryPhaseExecutionException[[test\_test][2]:  
> query[date\_published:[1279694418000 TO 1279694418000]],from[0],size[10]:  
> Query Failed ]; nested: }]"}
> 
> Stacktrace of es:
> 
> [14:55:38,875][DEBUG][action.search.type] [Heart Attack]  
> [test\_test][3], node[b59ce67f-7423-4c34-a966-6bfefc1f2294], [P], s[STARTED]:  
> Failed to execute [org.elasticsearch.action.search.SearchRequest@4d88e490]  
> org.elasticsearch.search.query.QueryPhaseExecutionException:  
> [test\_test][3]: query[date\_published:[1279694418000 TO  
> 1279694418000]],from[0],size[10]: Query Failed [Failed to execute main  
> query]  
> at  
> org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:124)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:169)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:129)  
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:77)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:194)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.access$000(TransportSearchTypeAction.java:80)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.run(TransportSearchTypeAction.java:153)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:637)  
> Caused by: java.lang.NullPointerException  
> at  
> org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:81)  
> ... 9 more
> 
> Hi,  
> Alberto

---

<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, 4:21am UTC](https://discuss.elastic.co/t/better-error-message-for-missing-index/3137/3 "2017-07-06T04:21:47Z")

</div>


