class_docstr: Search commands.
docstr: Issue an aggregation query.
  
  ### Parameters
  
  **query**: This can be either an `AggregateRequest`, or a `Cursor`
  
  An `AggregateResult` object is returned. You can access the rows from
  its `rows` property, which will always yield the rows of the result.
  
  For more information see `FT.AGGREGATE <https://redis.io/commands/ft.aggregate>`_.
docstr_tok: ["Issue","an","aggregation","query",".","#","#","#","Parameters","*","*","query","*","*",":","This","can","be","either","an","`","AggregateRequest","`",",","or","a","`","Cursor","`","An","`","AggregateResult","`","object","is","returned",".","You","can","access","the","rows","from","its","`","rows","`","property",",","which","will","always","yield","the","rows","of","the","result",".","For","more","information","see","`","FT.AGGREGATE","<","https",":","\/\/redis.io\/commands\/ft.aggregate",">","`","_","."]
code: def aggregate(
      self,
      query: Union[str, Query],
      query_params: Dict[str, Union[str, int, float]] = None,
  ):
      """
      Issue an aggregation query.
  
      ### Parameters
  
      **query**: This can be either an `AggregateRequest`, or a `Cursor`
  
      An `AggregateResult` object is returned. You can access the rows from
      its `rows` property, which will always yield the rows of the result.
  
      For more information see `FT.AGGREGATE <https://redis.io/commands/ft.aggregate>`_.
      """  # noqa
      if isinstance(query, AggregateRequest):
          has_cursor = bool(query._cursor)
          cmd = [AGGREGATE_CMD, self.index_name] + query.build_args()
      elif isinstance(query, Cursor):
          has_cursor = True
          cmd = [
              CURSOR_CMD,
              "READ",
              self.index_name,
          ] + query.build_args()
      else:
          raise ValueError("Bad query", query)
      cmd += self.get_params_args(query_params)
  
      raw = self.execute_command(*cmd)
      return self._parse_results(
          AGGREGATE_CMD, raw, query=query, has_cursor=has_cursor
      )
  
imports: import itertools
  import time
  from typing import Dict, List, Optional, Union
  from redis.client import Pipeline
  from redis.utils import deprecated_function
  from ..helpers import get_protocol_version, parse_to_dict
  from ._util import to_string
  from .aggregation import AggregateRequest, AggregateResult, Cursor
  from .document import Document
  from .query import Query
  from .result import Result
  from .suggestion import SuggestionParser
label_desc: Use image node_id 26 for calling the SearchCommands obj's underlying member method code with example usage: obj.aggregate(query, query_params) and returns: self