-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong mapping using a nested object with same name as its type #3005
Comments
The problem is that the top level element in the doc is called
So, in your case, make sure the mapping name is not the same as the top level element if you don't provide your json docs wrapped with the type name. |
Does anybody use that double type (ie url + json)? This seems like an alternative which could be removed fairly painlessly. |
Cool! I didn't know this was supposed to happen. I already changed the type name. On the other hand I'm not quite sure if anybody is actually using this feature. I would expect elasticsearch not to care too much about the content of my documents and give me a mapping like this:
My two cents: I would prefer to have the |
It all goes back to the early history of elasticsearch, a lot of users were confused about the double mapping when they were wrapping the document they were indexing with the type name (some auto domain_objects -> json tools do that). I agree that we could fail the indexing request if there is something we don't expect. |
I see! Well, if you want to be more backwards compatible you can probably check if the top level object with the type name is the only one available in the document (thus probably not needed) in order to avoid ignoring other nested objects, but I don't like this option that much myself. |
Yeah, I'd prefer there to be just one definitive way to do it, so that we don't have to guess. |
Would be good to resolve this issue in 1.0, even though it requires breaking bwc. The body of an indexing request should be just that: the body, not possibly the body wrapped in the type. Type should be specified only in the URL. |
I think this issue is also related to has_parent and has_child queries/filters: https://groups.google.com/d/msg/elasticsearch/8yTX17uoFiU/xGjYd4tfEzAJ |
When I index a document in elasticsearch 0.90.0 and I have nested objects, one of which has the same name as its type, the automatically submitted mapping is wrong and basic queries don't work anymore.
Here is the curl recreation: https://gist.github.com/javanna/5531326 .
Indexing an object like this under the "type" type, with empty mapping:
The updated mapping becomes the following:
I would expect to see a type2 nested object but I can't find it, and any query on the nested type2 object doesn't return any result.
The problem seems to be caused by the name of the type used to index the document, which is the same as the name of one the nested objects. If I change that I don't see any problem.
The text was updated successfully, but these errors were encountered: