Match a child document limited to its great-grandparent document

Hi there,

I'm trying to get some results of an index which has parent-child relationships set like so:

    PUT /attributes
        "mappings": {
            "properties": {
                "preset_to_attribute_to_group_to_category": {
                    "type": "join",
                    "relations": {
                        "category": "group",
                        "group": "attribute",
                        "attribute": "preset"

This creates the following chain:

Category -> group -> attribute -> preset

The set has 50k presets, around 4k attributes, and equal number of category/groups.

I'm totally new with Elastic, so even after getting 2 online courses, can't wrap my head around how could I retrieve something out of this index.

For example:
Every document consists of 2 pieces of information, the ID from the mysql db and the title/text/value.
So every preset consists of 2 pieces of information, an ID and a Text value (title)

PUT attributes/_doc?routing=1
    "preset_to_attribute_to_group_to_category": {
        "name": "preset",
        "parent": "an attribute id"
    "id": "preset id from source material",
    "title": "some preset title"

I need to match an input term to a specific preset title and get the id of the matching document (not the _id), but the result must be limited on the Grandparent of this preset (category) which is a few levels up. (if I get to this point, PHP takes over)

Return the preset with title "xyz" title in the "abc" category.
Categories are 2 levels up and are great-grandparents to presets

The relationships are build like this because there are numerous presets with the same Title text value (but different id) and belong to different attributes which in turn belong to different attribute groups.

Is this even possible? Does it make sense? Am I indexing the documents correctly ?

I reindexed it with a different approach, without Parent:Child relationships and it works as intended.

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