1

I'm using Elastisearch 5.x and Python with elasticsearch-dsl 5.2.0

I need to start querying from the Child, take a couple of fields, match it with a defined Father and Grandfather (from which Grandfather I also need a field value)

The problem is that in my search results the Grandfather inner_hits is empty. I could really use a tip here.

search = Child.search().source(
    includes=['a', 'b']
).filter(
    'term', child_id=child_id
).query(
    'has_parent',
    type='father',
    inner_hits={'name': 'father'},
    query=Q(
        Q('term', id=father_id) &
        Q(
            'has_parent',
            type='grandfather',
            inner_hits={'name': 'grandfather'},
            query=Q('term', _id=grandfather_id)
        )
    )
)


class Child(DocType):
    child_id = Keyword()
    a = Keyword()
    b = Keyword()

    class Meta:
        doc_type = 'child'
        parent = MetaField(type='father')

class Father(DocType):
    id = Integer()

    class Meta:
        doc_type = 'father'
        parent = MetaField(type='grandfather')

class Grandfather(DocType):
    grandfather_id = String()
    grandfatherFieldNeeded = String() 

    class Meta:
        doc_type = 'grandfather'
        parent = MetaField(type='notimportant')
user2091046
  • 585
  • 1
  • 8
  • 20

0 Answers0