Skip to content
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

Inner object with same name as type causes query issues #6108

Closed
rtkbkish opened this issue May 9, 2014 · 1 comment
Closed

Inner object with same name as type causes query issues #6108

rtkbkish opened this issue May 9, 2014 · 1 comment

Comments

@rtkbkish
Copy link

rtkbkish commented May 9, 2014

If I have an inner object that has the same name as a type, then queries for that inner object will fail.

The workaround is to rename the type or the inner object, but the behaviour is confusing and misleading (and wrong).

To reproduce, create a new index, type and document:
curl -XPOST 'localhost:9200/test/flow/' -d '{
"device": {
"id": "dummy"
}
}'

Querying for that document by device.id will work:
curl 'localhost:9200/test/_search?pretty' -d '{
"query":{
"filtered": {
"filter": {
"term": {
"device.id": "dummy"
}
}
}
}
}'

Add a type with the same name as the inner object, AND containing an inner object with that name as well:
curl -XPOST 'localhost:9200/test/device/' -d '{
"device": {
"id": "foo"
}
}'

Now querying for the original document by device.id will fail:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

Removing the 'device' type will allow the original document to be queryable again:
curl -XDELETE 'localhost:9200/test/device'

@clintongormley
Copy link
Contributor

Closed as duplicate of #4081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants