docs: def serialize(self):
          """Serialize the query to a structure using the query DSL."""
          data = {'doc': self.doc}
          if isinstance(self.query, Query):
              data['query'] = self.query.serialize()
          return data