Has no parent query

Is there any way of querying for documents of a certain type for those that
have no parent, or whose parent has been deleted?

I have a parent/child relationship in my system, and some parents have been
deleted, and so I would like to delete the orphan children, as they are no
longer required.

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

On Fri, 2013-03-01 at 20:57 -0800, Simon wrote:

Is there any way of querying for documents of a certain type for those
that have no parent, or whose parent has been deleted?

Not easily...

I'd suggest doing a scan query which returns all child docs in tranches.
Extract the parent ids from those and do an _ids query on those. Find
the ids which weren't returned -> missing parents.

clint

I have a parent/child relationship in my system, and some parents have
been deleted, and so I would like to delete the orphan children, as
they are no longer required.

Thanks!

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

On Sat, 2013-03-02 05:57:41 UTC+1, Simon wrote:

Is there any way of querying for documents of a certain type for
those that have no parent, or whose parent has been deleted? I have a
parent/child relationship in my system, and some parents have been
deleted, and so I would like to delete the orphan children, as they
are no longer required.

A rather late reply just for completeness: For me this worked using a "not"
with a "hasParent" filter:

"filter": {
"not": {
"filter": {
"has_parent": {
"query": {
"match_all": {}
},
"parent_type": "XXX"
}
}
}
}

Hannes

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

\nn/ :wink:

On Thursday, August 29, 2013 12:50:27 PM UTC+2, Hannes Korte wrote:

On Sat, 2013-03-02 05:57:41 UTC+1, Simon wrote:

Is there any way of querying for documents of a certain type for
those that have no parent, or whose parent has been deleted? I have a
parent/child relationship in my system, and some parents have been
deleted, and so I would like to delete the orphan children, as they
are no longer required.

A rather late reply just for completeness: For me this worked using a
"not" with a "hasParent" filter:

"filter": {
"not": {
"filter": {
"has_parent": {
"query": {
"match_all": {}
},
"parent_type": "XXX"
}
}
}
}

Hannes

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.