'Serialize the query to a structure using the query DSL.'

def serialize(self):

    data = {'doc': self.doc}
    if isinstance(self.query, Query):
        data['query'] = self.query.serialize()
    return data
