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

def serialize(self):

    data = {self._internal_name: self.query.serialize()}
    if (self.query_weight is not None):
        data['query_weight'] = self.query_weight
    if (self.rescore_query_weight is not None):
        data['rescore_query_weight'] = self.rescore_query_weight
    return data
