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

The has_parent request is broken for self-referential parent types #7357

Closed
imotov opened this issue Aug 20, 2014 · 2 comments
Closed

The has_parent request is broken for self-referential parent types #7357

imotov opened this issue Aug 20, 2014 · 2 comments
Assignees
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@imotov
Copy link
Contributor

imotov commented Aug 20, 2014

We don't explicitly prohibit types from referring to themselves as parents. This functionality worked fine before 0.90 release, but since 0.90 it seems to be broken for the has_parent query. In the following script, both search requests return results in 0.20.x but only the second search request returns results in 0.90.x and above.

curl -XDELETE localhost:9200/test-idx
curl -XPUT localhost:9200/test-idx -d '{
    "settings": {
        "index.number_of_shards": 1,
        "index.number_of_replicas": 0
    },
    "mappings": {
        "doc": {
            "_parent": {
                "type": "doc"
            }
        }
    }
}'
curl -XPUT "localhost:9200/test-idx/doc/1?routing=1&pretty" -d '{"name": "doc_1"}'
curl -XPUT "localhost:9200/test-idx/doc/2?parent=1&pretty" -d '{"name": "doc_2"}'
curl -XPOST "localhost:9200/test-idx/_refresh?pretty"
echo
curl "localhost:9200/test-idx/doc/_search?pretty" -d '{
    "query": {
        "has_parent": {
            "type": "doc",
            "query" : {
                "match_all": {
                }
            }
        }
    }
}'
echo
curl "localhost:9200/test-idx/doc/_search?pretty" -d '{
    "query": {
        "has_child": {
            "type": "doc",
            "query" : {
                "match_all": {
                }
            }
        }
    }
}'

search result in 0.20.6:

{
  "took" : 54,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test-idx",
      "_type" : "doc",
      "_id" : "2",
      "_score" : 1.0, "_source" : {"name": "doc_2"}
    } ]
  }
}
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test-idx",
      "_type" : "doc",
      "_id" : "1",
      "_score" : 1.0, "_source" : {"name": "doc_1"}
    } ]
  }
}

search result in the current master:

{
  "took" : 66,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}

{
  "took" : 16,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test-idx",
      "_type" : "doc",
      "_id" : "1",
      "_score" : 1.0,
      "_source":{"name": "doc_1"}
    } ]
  }
}
@imotov imotov added the bug label Aug 20, 2014
@martijnvg martijnvg self-assigned this Aug 27, 2014
@pbhuyanieee
Copy link

This came up during the training session in Boston. We have use case which could use this feature.

@martijnvg
Copy link
Member

Closing in favor for #11432

@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Parent/Child labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

No branches or pull requests

4 participants