Description:
I'm facing a challenge with formulating an Elasticsearch query to retrieve dependencies related to a given parent_id
. Here's a brief description of the problem:
I have a set of independent documents with fields like identifier
, parent_id
, ticket_title
, and ticket_type
. The goal is to query all dependencies for documents with the ticket_type
"Task," even when parent_id
has its own set of dependencies. These dependencies can form a chain, and the nesting level is not consistent across documents.
Typically, Elasticsearch uses nested or parent-child relationships for hierarchical data, but in this case, the documents are independent. I'm seeking assistance in formulating a query that can effectively navigate through the dependencies, regardless of their nested or independent nature, and provide a comprehensive view of all related dependencies for a given parent_id
. I'm also interested if I can query to which project this task is contributing.
Example:
PUT ticket_parent/_doc/1
{
"identifier" : 1,
"parent_id" : 2,
"ticket_title": "Im a task",
"ticket_type":"Task"
}
PUT ticket_parent/_doc/2
{
"identifier" : 2,
"ticket_title": "Im a story",
"parent_id" : 3,
"ticket_type":"Story",
"child_id" : 1
}
PUT ticket_parent/_doc/3
{
"identifier" : 3,
"ticket_title": "Im a feature",
"ticket_type":"Feature",
"child_id" : 2,
"project" : "foobar"
}
I've tried using the "terms" aggregation for parent_id
, but the results aren't capturing all dependencies. Any suggestions or guidance on constructing a suitable Elasticsearch query for this scenario would be greatly appreciated.
Thank you!