404 on _mapping with empty database

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/
_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 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

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.

On Wed, May 23, 2012 at 8:15 PM, betabug-sw 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/
_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 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