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

has_child returns parent and child #2744

Closed
clintongormley opened this issue Mar 7, 2013 · 3 comments
Closed

has_child returns parent and child #2744

clintongormley opened this issue Mar 7, 2013 · 3 comments

Comments

@clintongormley
Copy link

When I run a has_child query on 0.20.5, it is returning both the child and the parent:

curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1'  -d '
{
   "mappings" : {
      "test" : {
         "_parent" : {
            "type" : "foo"
         }
      }
   }
}
'

curl -XPUT 'http://127.0.0.1:9200/test/foo/1?pretty=1'  -d '
{
   "foo" : 1
}
'

# {
#    "ok" : true,
#    "_index" : "test",
#    "_id" : "1",
#    "_type" : "foo",
#    "_version" : 1
# }

curl -XPOST 'http://127.0.0.1:9200/test/test?parent=1&pretty=1'  -d '
{
   "foo" : 1
}
'

# {
#    "ok" : true,
#    "_index" : "test",
#    "_id" : "GBEoJRcGQnCDN93_JiUAKQ",
#    "_type" : "test",
#    "_version" : 1
# }


curl -XGET 'http://127.0.0.1:9200/test/_search?pretty=1'  -d '
{
   "query" : {
      "has_child" : {
         "query" : {
            "match" : {
               "foo" : 1
            }
         },
         "type" : "test"
      }
   }
}
'

# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "foo" : 1
#             },
#             "_score" : 1,
#             "_index" : "test",
#             "_id" : "1",
#             "_type" : "foo"
#          },
#          {
#             "_source" : {
#                "foo" : 1
#             },
#             "_score" : 1,
#             "_index" : "test",
#             "_id" : "GBEoJRcGQnCDN93_JiUAKQ",
#             "_type" : "test"
#          }
#       ],
#       "max_score" : 1,
#       "total" : 2
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 3
# }
@s1monw
Copy link
Contributor

s1monw commented Mar 9, 2013

this should only return the parent? Excuse my naive question ;)

@clintongormley
Copy link
Author

Yes

@s1monw
Copy link
Contributor

s1monw commented Mar 11, 2013

ok ;) do you know if this happens on master too?

s1monw added a commit to s1monw/elasticsearch that referenced this issue Mar 11, 2013
@s1monw s1monw closed this as completed in 237c4dd Mar 11, 2013
s1monw added a commit that referenced this issue Mar 11, 2013
… null ie. if the document has a parent.

Closes #2744
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants