# 404 on \_mapping with empty database

**URL:** <https://discuss.elastic.co/t/404-on--mapping-with-empty-database/7826>\
**Category:** Elasticsearch\
**Created:** [May 23, 2012, 6:15pm UTC](https://discuss.elastic.co/t/404-on--mapping-with-empty-database/7826 "2012-05-23T18:15:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![betabug\_sw](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@betabug\_sw](https://discuss.elastic.co/u/betabug_sw)\
**Post date:** [May 23, 2012, 6:15pm UTC](https://discuss.elastic.co/t/404-on--mapping-with-empty-database/7826/1 "2012-05-23T18:15:35Z")

</div>

Hi!

Up till version 19.1 of Elasticsearch, getting '/\_mapping' on an  
empty data storage (no indexes, no nothing, freshly installed)  
would return {} and give a status of 200.

19.2+ correctly returns {}, but gives a status 404:

es/elasticsearch-0.19.4$ curl -v -XGET '[http://127.0.0.1:9200/](http://127.0.0.1:9200/)  
\_mapping'

- About to connect() to 127.0.0.1 port 9200 (#0)
- Trying 127.0.0.1...
- connected
- Connected to 127.0.0.1 (127.0.0.1) port 9200 (#0)

> GET /\_mapping HTTP/1.1  
> User-Agent: curl/7.25.0 (x86\_64-unknown-openbsd5.1) libcurl/7.25.0 OpenSSL/1.0.0f zlib/1.2.3 libidn/1.24  
> Host: 127.0.0.1:9200  
> Accept: _/_

\< HTTP/1.1 404 Not Found  
\< Content-Type: application/json; charset=UTF-8  
\< Content-Length: 2  
\<

- Connection #0 to host 127.0.0.1 left intact  
{}\* Closing connection #0

It's not obvious if this is intentional - on returning a 404 error  
status  
I wouldn't expect the data to be in there.

(I've posted this to [Elasticsearch 19.2+ gives 404 on '/\_mapping' with an empty data storage · GitHub](https://gist.github.com/2776724) too.)

Is this a bug or should I simply prepared to get a 404? (I'm mainly  
using this within automated tests.)

Thanks for taking the time to look at this!

Regards,  
Sascha

---

<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:** [May 23, 2012, 10:56pm UTC](https://discuss.elastic.co/t/404-on--mapping-with-empty-database/7826/2 "2012-05-23T22:56:38Z")

</div>

Yea, its a bug. The idea was to return 404 properly if nothing was found  
(something that was not done properly). Here is the issue:  
[Get mapping with no index specified on an empty cluster returns 404 · Issue #1976 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1976).

On Wed, May 23, 2012 at 8:15 PM, betabug-sw [throwaway3@betabug.ch](mailto:throwaway3@betabug.ch) wrote:

> Hi!
> 
> Up till version 19.1 of Elasticsearch, getting '/\_mapping' on an  
> empty data storage (no indexes, no nothing, freshly installed)  
> would return {} and give a status of 200.
> 
> 19.2+ correctly returns {}, but gives a status 404:
> 
> es/elasticsearch-0.19.4$ curl -v -XGET '[http://127.0.0.1:9200/](http://127.0.0.1:9200/)  
> \_mapping'
> 
> - About to connect() to 127.0.0.1 port 9200 (#0)
> - Trying 127.0.0.1...
> - connected
> - Connected to 127.0.0.1 (127.0.0.1) port 9200 (#0)
> 
> > GET /\_mapping HTTP/1.1  
> > User-Agent: curl/7.25.0 (x86\_64-unknown-openbsd5.1) libcurl/7.25.0  
> > OpenSSL/1.0.0f zlib/1.2.3 libidn/1.24  
> > Host: 127.0.0.1:9200  
> > Accept: _/_
> 
> \< HTTP/1.1 404 Not Found  
> \< Content-Type: application/json; charset=UTF-8  
> \< Content-Length: 2  
> \<
> 
> - Connection #0 to host 127.0.0.1 left intact  
> {}\* Closing connection #0
> 
> It's not obvious if this is intentional - on returning a 404 error  
> status  
> I wouldn't expect the data to be in there.
> 
> (I've posted this to [Elasticsearch 19.2+ gives 404 on '/\_mapping' with an empty data storage · GitHub](https://gist.github.com/2776724) too.)
> 
> Is this a bug or should I simply prepared to get a 404? (I'm mainly  
> using this within automated tests.)
> 
> Thanks for taking the time to look at this!
> 
> Regards,  
> Sascha

---

<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, 3:27am UTC](https://discuss.elastic.co/t/404-on--mapping-with-empty-database/7826/3 "2017-07-06T03:27:24Z")

</div>


