Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Don't accept type wrapper in index request #4484
Currently it is possible to index a document as:
This makes indexing non-deterministic and fields can be misinterpreted as type names.
We should accept only the first form, ie without the type wrapper.
referenced this issue
Dec 17, 2013
referenced this issue
Dec 26, 2013
I have concerns about this change... . The reason why it was supported to begin with was that some serialization tools that convert objects to json objects tend to sometime also include a top level "type" in it... (not many, I admit...).
I am also concerned about the backward comp. questions that will happen here..., I know we can break 1.0 backward comp., but this can be very annoying (think about users relaying on it, and now they will need to somehow strip the top level).
I agree that currently, its annoying, because if a json document has the first field name the same as the type, its very annoying since it breaks badly. Which I think this is where this change is coming from.
But, at the end, if we can support the above, if there is a single top level object, and thats the same as the type name, then we treat it as the type, and parse the fields within it. If its not (its a field, or there is another object at the same level), then treat it as a "regular" document. If we manage to do this, then I would say its better.
I have never seen anybody gist an example where they index a document with the body wrapped with the type name. I have however seen a few people have issues because of the ambiguity introduced by supporting optional type wrapping. Better heuristics may make the issue less frequent, but won't solve it completely.
I'd vote for pushing the change as it is or, alternatively, adding a setting which allows the user to continue using the old behaviour should they so choose, but disable it by default.
I agree with Clint also, I've never seen anyone index documents wrapped by the type name, and trying to determine whether the outer object is a type-name or object-name will be confusing to the end user since the decision is hidden inside internal ES logic. I think we should remove the wrapping option. What do you think @kimchy?