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

Nested query returns no result when nested object has the same field name as parent #10753

Closed
agliznetsov opened this issue Apr 23, 2015 · 3 comments

Comments

@agliznetsov
Copy link

  1. create index with nested mappings:

{
"mappings": {
"movie": {
"properties": {
"cast": {
"type": "nested"
}
}
}
}
}

  1. post a document:

{
"title": "The Matrix",
"cast": [
{
"title": "test"
}
]
}

  1. search nested:

{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"nested": {
"path": "cast",
"filter": {
"term": {
"title": "test"
}
}
}
}
}
}
}

no result found -> bug

It works if nested object uses different field name rather then 'title'

@rjernst
Copy link
Member

rjernst commented Apr 23, 2015

I don't think this has anything to do with the field names being the same, since the type of both are string. I believe this is related to #8872. Can you change your term query to use cast.title as the field and see if it works?

@agliznetsov
Copy link
Author

Indeed it works with "cast.title". Does it mean that a full path must be used in the term despite the fact that there's also a path specified one level higher?

@clintongormley
Copy link
Contributor

@agliznetsov yes that is the case with nested clauses. In fact, in 2.0 it will be the case for ALL fields. See #8070

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

3 participants