Elasticsearch: invalid empty json on 404 INDEX/_doc/ID/_source

Created on 4 Sep 2018  路  8Comments  路  Source: elastic/elasticsearch

GET /existing-index/_doc/notexisting-id/_source
returns empty body when document is not found.
Empty string is invalid json but content-type of response is application/json; charset=UTF-8
it whould be better if response body will be null to make json parser happy

:CorFeatureIndices APIs >bug

All 8 comments

elasticsearch version 6.4

Pinging @elastic/es-core-infra

@jasontedor marked this as "discuss", but I think this should be a bug. Empty body is not a valid return for the json content type (even if it's a 404). "null" sounds like a better choice here.

We discussed this in the core-infra team meeting and want to do the following:

  • If the document is not found, raise a resource not found exception and return this as a proper JSON body
  • If source is disabled also raise an exception and return this as a proper JSON body.

I'd like to have a look at this one.

cURL recreation script created in this Gist.

I'd like to have a look at this one.

Enjoy!

PR is open, see https://github.com/elastic/elasticsearch/pull/34083.

I've built on top of the previous behavior. This means we don't make a difference when source is disabled or document is missing: in both cases a ResourceNotFoundException is raised with the same JSON message.
Do you think a difference should be made?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

malpani picture malpani  路  3Comments

ppf2 picture ppf2  路  3Comments

jpountz picture jpountz  路  3Comments

matthughes picture matthughes  路  3Comments

clintongormley picture clintongormley  路  3Comments