Parent child search

Hi all

1). I have created a parent table named "dbparent" with 3 child
tables(child1, child2 child3).

2). In parent i have created 3 rows, and the same i have added the
rows for child table.

  1. If i search like below

      curl -XGET 'http://192.168.0.12:9200/dbparent1/_search' -d
    

'{"query" : {"has_child" : {"type" : "child", "query" :{"term" :
{"tag" : "something"} } } } }'

Result of this query is parent of the child.

Questions:

  1. Here i need a result as both parent and child record.?

  2. Is it possible to get child's of a parent?

  1. Still not implemented (getting the children per "parent" hit).
  2. You can do a term query: "term" : { "child_type._parent" : "parent_id" }

On Thu, Dec 30, 2010 at 9:26 AM, Arulkumar arulkumarcs@gmail.com wrote:

Hi all

1). I have created a parent table named "dbparent" with 3 child
tables(child1, child2 child3).

2). In parent i have created 3 rows, and the same i have added the
rows for child table.

  1. If i search like below

     curl -XGET 'http://192.168.0.12:9200/dbparent1/_search' -d
    

'{"query" : {"has_child" : {"type" : "child", "query" :{"term" :
{"tag" : "something"} } } } }'

Result of this query is parent of the child.

Questions:

  1. Here i need a result as both parent and child record.?

  2. Is it possible to get child's of a parent?

thank you shay

On Dec 30, 4:21 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

  1. Still not implemented (getting the children per "parent" hit).
  2. You can do a term query: "term" : { "child_type._parent" : "parent_id" }

On Thu, Dec 30, 2010 at 9:26 AM, Arulkumar arulkuma...@gmail.com wrote:

Hi all

1). I have created a parent table named "dbparent" with 3 child
tables(child1, child2 child3).

2). In parent i have created 3 rows, and the same i have added the
rows for child table.

  1. If i search like below
     curl -XGET 'http://192.168.0.12:9200/dbparent1/_search'-d

'{"query" : {"has_child" : {"type" : "child", "query" :{"term" :
{"tag" : "something"} } } } }'

Result of this query is parent of the child.

Questions:

  1. Here i need a result as both parent and child record.?
  1. Is it possible to get child's of a parent?

can you explain in detail with sample query about "child_type._parent"
and about parent_id?

On Dec 30, 4:26 pm, Arulkumar arulkuma...@gmail.com wrote:

thank you shay

On Dec 30, 4:21 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

  1. Still not implemented (getting the children per "parent" hit).
  2. You can do a term query: "term" : { "child_type._parent" : "parent_id" }

On Thu, Dec 30, 2010 at 9:26 AM, Arulkumar arulkuma...@gmail.com wrote:

Hi all

1). I have created a parent table named "dbparent" with 3 child
tables(child1, child2 child3).

2). In parent i have created 3 rows, and the same i have added the
rows for child table.

  1. If i search like below
     curl -XGET 'http://192.168.0.12:9200/dbparent1/_search'-d

'{"query" : {"has_child" : {"type" : "child", "query" :{"term" :
{"tag" : "something"} } } } }'

Result of this query is parent of the child.

Questions:

  1. Here i need a result as both parent and child record.?
  1. Is it possible to get child's of a parent?

What don't you understand specifically? the child_type._parent is the
ability to use type_name.field_name notation. Something like tweet.message
(so the result is automatically filtered to tweet types). The "parent_id" in
question is simply the value of the parent id you want to find childs for.
Wrap it in a term query and execute a search request with it, and you will
get the children of a specific parent.

On Thu, Dec 30, 2010 at 1:41 PM, Arulkumar arulkumarcs@gmail.com wrote:

can you explain in detail with sample query about "child_type._parent"
and about parent_id?

On Dec 30, 4:26 pm, Arulkumar arulkuma...@gmail.com wrote:

thank you shay

On Dec 30, 4:21 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

  1. Still not implemented (getting the children per "parent" hit).
  2. You can do a term query: "term" : { "child_type._parent" :
    "parent_id" }

On Thu, Dec 30, 2010 at 9:26 AM, Arulkumar arulkuma...@gmail.com
wrote:

Hi all

1). I have created a parent table named "dbparent" with 3 child
tables(child1, child2 child3).

2). In parent i have created 3 rows, and the same i have added the
rows for child table.

  1. If i search like below
     curl -XGET 'http://192.168.0.12:9200/dbparent1/_search'-d

'{"query" : {"has_child" : {"type" : "child", "query" :{"term" :
{"tag" : "something"} } } } }'

Result of this query is parent of the child.

Questions:

  1. Here i need a result as both parent and child record.?
  1. Is it possible to get child's of a parent?

Can this also be accomplished through a StringQuery? I would like users to be able to find all children with a certain parent (without having to store the parent_id independently). I am not having much luck with a StringQuery "_parent:ID1234567" when applied to the the child_type.

-b

Can you gist a curl recreation of this? It should work.
On Thursday, January 27, 2011 at 8:23 PM, byuva wrote:

Can this also be accomplished through a StringQuery? I would like users to
be able to find all children with a certain parent (without having to store
the parent_id independently). I am not having much luck with a StringQuery
"_parent:ID1234567" when applied to the the child_type.

-b

View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Parent-child-search-tp2166479p2363405.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

I have it figured out now. I had been unable to see the actual content of the _parent field (per another thread here) and hadn't realized that the name was slightly mangled (eg "my_parent_type#my_id). My apologies if I missed this in the documentation.

-brian

That should not be the case, opened an issue for this: Search: When fetching _parent, only the _id should be returned, and not type#id · Issue #658 · elastic/elasticsearch · GitHub and pushed a fix.

As for matching on _parent field, you can simple do a term query on child_type._parent:parent_id.
On Sunday, January 30, 2011 at 7:49 PM, byuva wrote:

I have it figured out now. I had been unable to see the actual content of
the _parent field (per another thread here) and hadn't realized that the
name was slightly mangled (eg "my_parent_type#my_id). My apologies if I
missed this in the documentation.

-brian

--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Parent-child-search-tp2166479p2384355.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.