Parent Id query problem

Hi!

I have a problem with a test that i've run with Kibana and ES 5.1

If I have understood the doc correctly, those 2 requests should return the same result, but it's not the case :

GET /gangs/_search
{
  "query": {
    "parent_id" : {
      "type" : "gang",
      "id" : "gang1"
    }
  }
}

GET /gangs/_search
{
  "query": {
    "has_parent": {
      "parent_type": "gang",
        "query": {
          "term": {
            "_id": "gang1"
        }
      }
    }
  }
}

The first query return an error : "[parent_id] _parent field has no parent type configured" and the second one return the expected document.

Here is my test setup on pastebin: http://pastebin.com/vPW6ieUV

Hi,

Your "gangs" indice holds 3 types of documents: gang, territory & entity. When you run your query on /gangs, it apply the query on all types, so it return an error for "gang" type because it doesn't have a _parent field.
Try to run your query on only one or two types having a _parent field:

GET /gangs/territory/_search
{
  "query": {
"parent_id" : {
  "type" : "gang",
  "id" : "gang1"
}
  }
}

Actually, i've found my mistake. I misread the documentation:

I was doing a query whith the parent type in the "type" field of the "parent_id" query, where you should use the child type.

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.