docs: def serialize(self):
          """Serialize the query to a structure using the query DSL."""
  
          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