{
  "id": "query",
  "title": "Query",
  "url": "https://redis.io/docs/latest/develop/ai/redisvl/0.14.0/api/query/",
  "summary": "",
  "content": "\n\nQuery classes in RedisVL provide a structured way to define simple or complex\nqueries for different use cases. Each query class wraps the `redis-py` Query module\n[https://github.com/redis/redis-py/blob/master/redis/commands/search/query.py](https://github.com/redis/redis-py/blob/master/redis/commands/search/query.py) with extended functionality for ease-of-use.\n\n## VectorQuery\n\n### `class VectorQuery(vector, vector_field_name, return_fields=None, filter_expression=None, dtype='float32', num_results=10, return_score=True, dialect=2, sort_by=None, in_order=False, hybrid_policy=None, batch_size=None, ef_runtime=None, epsilon=None, search_window_size=None, use_search_history=None, search_buffer_capacity=None, normalize_vector_distance=False)`\n\nBases: `BaseVectorQuery`, `BaseQuery`\n\nA query for running a vector search along with an optional filter\nexpression.\n\n* **Parameters:**\n  * **vector** (*List* *[* *float* *]*) – The vector to perform the vector search with.\n  * **vector_field_name** (*str*) – The name of the vector field to search\n    against in the database.\n  * **return_fields** (*List* *[* *str* *]*) – The declared fields to return with search\n    results.\n  * **filter_expression** (*Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *,* *optional*) – A filter to apply\n    along with the vector search. Defaults to None.\n  * **dtype** (*str* *,* *optional*) – The dtype of the vector. Defaults to\n    \"float32\".\n  * **num_results** (*int* *,* *optional*) – The top k results to return from the\n    vector search. Defaults to 10.\n  * **return_score** (*bool* *,* *optional*) – Whether to return the vector\n    distance. Defaults to True.\n  * **dialect** (*int* *,* *optional*) – The RediSearch query dialect.\n    Defaults to 2.\n  * **sort_by** (*Optional* *[* *SortSpec* *]*) – The field(s) to order the results by. Can be:\n    - str: single field name\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\")\n    - List: list of fields or tuples\n    Note: Only the first field is used for Redis sorting.\n    Defaults to None. Results will be ordered by vector distance.\n  * **in_order** (*bool*) – Requires the terms in the field to have\n    the same order as the terms in the query filter, regardless of\n    the offsets between them. Defaults to False.\n  * **hybrid_policy** (*Optional* *[* *str* *]*) – Controls how filters are applied during vector search.\n    Options are \"BATCHES\" (paginates through small batches of nearest neighbors) or\n    \"ADHOC_BF\" (computes scores for all vectors passing the filter).\n    \"BATCHES\" mode is typically faster for queries with selective filters.\n    \"ADHOC_BF\" mode is better when filters match a large portion of the dataset.\n    Defaults to None, which lets Redis auto-select the optimal policy.\n  * **batch_size** (*Optional* *[* *int* *]*) – When hybrid_policy is \"BATCHES\", controls the number\n    of vectors to fetch in each batch. Larger values may improve performance\n    at the cost of memory usage. Only applies when hybrid_policy=\"BATCHES\".\n    Defaults to None, which lets Redis auto-select an appropriate batch size.\n  * **ef_runtime** (*Optional* *[* *int* *]*) – Controls the size of the dynamic candidate list for HNSW\n    algorithm at query time. Higher values improve recall at the expense of\n    slower search performance. Defaults to None, which uses the index-defined value.\n  * **epsilon** (*Optional* *[* *float* *]*) – The range search approximation factor for HNSW and SVS-VAMANA\n    indexes. Sets boundaries for candidates within radius \\* (1 + epsilon). Higher values\n    allow more extensive search and more accurate results at the expense of run time.\n    Defaults to None, which uses the index-defined value (typically 0.01).\n  * **search_window_size** (*Optional* *[* *int* *]*) – The size of the search window for SVS-VAMANA KNN searches.\n    Increasing this value generally yields more accurate but slower search results.\n    Defaults to None, which uses the index-defined value (typically 10).\n  * **use_search_history** (*Optional* *[* *str* *]*) – For SVS-VAMANA indexes, controls whether to use the\n    search buffer or entire search history. Options are \"OFF\", \"ON\", or \"AUTO\".\n    \"AUTO\" is always evaluated internally as \"ON\". Using the entire history may yield\n    a slightly better graph at the cost of more search time.\n    Defaults to None, which uses the index-defined value (typically \"AUTO\").\n  * **search_buffer_capacity** (*Optional* *[* *int* *]*) – Tuning parameter for SVS-VAMANA indexes using\n    two-level compression (LVQ\u003cX\u003ex\u003cY\u003e or LeanVec types). Determines the number of vector\n    candidates to collect in the first level of search before the re-ranking level.\n    Defaults to None, which uses the index-defined value (typically SEARCH_WINDOW_SIZE).\n  * **normalize_vector_distance** (*bool*) – Redis supports 3 distance metrics: L2 (euclidean),\n    IP (inner product), and COSINE. By default, L2 distance returns an unbounded value.\n    COSINE distance returns a value between 0 and 2. IP returns a value determined by\n    the magnitude of the vector. Setting this flag to true converts COSINE and L2 distance\n    to a similarity score between 0 and 1. Note: setting this flag to true for IP will\n    throw a warning since by definition COSINE similarity is normalized IP.\n* **Raises:**\n  **TypeError** – If filter_expression is not of type redisvl.query.FilterExpression\n\n#### `NOTE`\nLearn more about vector queries in Redis: [https://redis.io/docs/latest/develop/ai/search-and-query/vectors/#knn-vector-search](https://redis.io/docs/latest/develop/ai/search-and-query/vectors/#knn-vector-search)\n\n#### `dialect(dialect)`\n\nAdd a dialect field to the query.\n\n- **dialect** - dialect version to execute the query under\n\n* **Parameters:**\n  **dialect** (*int*)\n* **Return type:**\n  *Query*\n\n#### `expander(expander)`\n\nAdd an expander field to the query.\n\n- **expander** - the name of the expander\n\n* **Parameters:**\n  **expander** (*str*)\n* **Return type:**\n  *Query*\n\n#### `in_order()`\n\nMatch only documents where the query terms appear in\nthe same order in the document.\ni.e., for the query \"hello world\", we do not match \"world hello\"\n\n* **Return type:**\n  *Query*\n\n#### `language(language)`\n\nAnalyze the query as being in the specified language.\n\n* **Parameters:**\n  **language** (*str*) – The language (e.g. chinese or english)\n* **Return type:**\n  *Query*\n\n#### `limit_fields(*fields)`\n\nLimit the search to specific TEXT fields only.\n\n- **fields**: Each element should be a string, case sensitive field name\n\nfrom the defined schema.\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *Query*\n\n#### `limit_ids(*ids)`\n\nLimit the results to a specific set of pre-known document\nids of any length.\n\n* **Return type:**\n  *Query*\n\n#### `no_content()`\n\nSet the query to only return ids and not the document content.\n\n* **Return type:**\n  *Query*\n\n#### `no_stopwords()`\n\nPrevent the query from being filtered for stopwords.\nOnly useful in very big queries that you are certain contain\nno stopwords.\n\n* **Return type:**\n  *Query*\n\n#### `paging(offset, num)`\n\nSet the paging for the query (defaults to 0..10).\n\n- **offset**: Paging offset for the results. Defaults to 0\n- **num**: How many results do we want\n\n* **Parameters:**\n  * **offset** (*int*)\n  * **num** (*int*)\n* **Return type:**\n  *Query*\n\n#### `query_string()`\n\nReturn the query string of this query only.\n\n* **Return type:**\n  str\n\n#### `return_fields(*fields, skip_decode=None)`\n\nSet the fields to return with search results.\n\n* **Parameters:**\n  * **\\*fields** – Variable number of field names to return.\n  * **skip_decode** (*List* *[* *str* *]*  *|* *str* *|* *None*) – Optional field name or list of field names that should not be\n    decoded. Useful for binary data like embeddings.\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  **TypeError** – If skip_decode is not a string, list, or None.\n\n#### `scorer(scorer)`\n\nUse a different scoring function to evaluate document relevance.\nDefault is TFIDF.\n\nSince Redis 8.0 default was changed to BM25STD.\n\n* **Parameters:**\n  **scorer** (*str*) – The scoring function to use\n  (e.g. TFIDF.DOCNORM or BM25)\n* **Return type:**\n  *Query*\n\n#### `set_batch_size(batch_size)`\n\nSet the batch size for the query.\n\n* **Parameters:**\n  **batch_size** (*int*) – The batch size to use when hybrid_policy is \"BATCHES\".\n* **Raises:**\n  * **TypeError** – If batch_size is not an integer\n  * **ValueError** – If batch_size is not positive\n\n#### `set_ef_runtime(ef_runtime)`\n\nSet the EF_RUNTIME parameter for the query.\n\n* **Parameters:**\n  **ef_runtime** (*int*) – The EF_RUNTIME value to use for HNSW algorithm.\n  Higher values improve recall at the expense of slower search.\n* **Raises:**\n  * **TypeError** – If ef_runtime is not an integer\n  * **ValueError** – If ef_runtime is not positive\n\n#### `set_epsilon(epsilon)`\n\nSet the epsilon parameter for the query.\n\n* **Parameters:**\n  **epsilon** (*float*) – The range search approximation factor for HNSW and SVS-VAMANA\n  indexes. Sets boundaries for candidates within radius \\* (1 + epsilon).\n  Higher values allow more extensive search and more accurate results at the\n  expense of run time.\n* **Raises:**\n  * **TypeError** – If epsilon is not a float or int\n  * **ValueError** – If epsilon is negative\n\n#### `set_filter(filter_expression=None)`\n\nSet the filter expression for the query.\n\n* **Parameters:**\n  **filter_expression** (*Optional* *[* *Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *]* *,* *optional*) – The filter\n  expression or query string to use on the query.\n* **Raises:**\n  **TypeError** – If filter_expression is not a valid FilterExpression or string.\n\n#### `set_hybrid_policy(hybrid_policy)`\n\nSet the hybrid policy for the query.\n\n* **Parameters:**\n  **hybrid_policy** (*str*) – The hybrid policy to use. Options are \"BATCHES\"\n  or \"ADHOC_BF\".\n* **Raises:**\n  **ValueError** – If hybrid_policy is not one of the valid options\n\n#### `set_search_buffer_capacity(search_buffer_capacity)`\n\nSet the SEARCH_BUFFER_CAPACITY parameter for the query.\n\n* **Parameters:**\n  **search_buffer_capacity** (*int*) – Tuning parameter for SVS-VAMANA indexes using\n  two-level compression. Determines the number of vector candidates to collect\n  in the first level of search before the re-ranking level.\n* **Raises:**\n  * **TypeError** – If search_buffer_capacity is not an integer\n  * **ValueError** – If search_buffer_capacity is not positive\n\n#### `set_search_window_size(search_window_size)`\n\nSet the SEARCH_WINDOW_SIZE parameter for the query.\n\n* **Parameters:**\n  **search_window_size** (*int*) – The size of the search window for SVS-VAMANA KNN searches.\n  Increasing this value generally yields more accurate but slower search results.\n* **Raises:**\n  * **TypeError** – If search_window_size is not an integer\n  * **ValueError** – If search_window_size is not positive\n\n#### `set_use_search_history(use_search_history)`\n\nSet the USE_SEARCH_HISTORY parameter for the query.\n\n* **Parameters:**\n  **use_search_history** (*str*) – For SVS-VAMANA indexes, controls whether to use the\n  search buffer or entire search history. Options are \"OFF\", \"ON\", or \"AUTO\".\n* **Raises:**\n  * **TypeError** – If use_search_history is not a string\n  * **ValueError** – If use_search_history is not one of \"OFF\", \"ON\", or \"AUTO\"\n\n#### `slop(slop)`\n\nAllow a maximum of N intervening non-matched terms between\nphrase terms (0 means exact phrase).\n\n* **Parameters:**\n  **slop** (*int*)\n* **Return type:**\n  *Query*\n\n#### `sort_by(sort_spec=None, asc=True)`\n\nSet the sort order for query results.\n\nThis method supports sorting by single or multiple fields. Note that Redis Search\nnatively supports only a single SORTBY field. When multiple fields are specified,\nonly the FIRST field is used for the Redis SORTBY clause.\n\n* **Parameters:**\n  * **sort_spec** (*str* *|* *Tuple* *[* *str* *,* *str* *]*  *|* *List* *[* *str* *|* *Tuple* *[* *str* *,* *str* *]* *]*  *|* *None*) – Sort specification in various formats:\n    - str: single field name\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\")\n    - List: list of field names or tuples\n  * **asc** (*bool*) – Default sort direction when not specified (only used when sort_spec is a string).\n    Defaults to True (ascending).\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  * **TypeError** – If sort_spec is not a valid type.\n  * **ValueError** – If direction is not \"ASC\" or \"DESC\".\n\n### `Examples`\n\n```pycon\n\u003e\u003e query.sort_by(\"price\")  # Single field, ascending\n\u003e\u003e query.sort_by((\"price\", \"DESC\"))  # Single field, descending\n\u003e\u003e query.sort_by([\"price\", \"rating\"])  # Multiple fields (only first used)\n\u003e\u003e query.sort_by([(\"price\", \"DESC\"), (\"rating\", \"ASC\")])\n```\n\n#### `NOTE`\nWhen multiple fields are specified, only the first field is used for sorting\nin Redis. Future versions may support multi-field sorting through post-query\nsorting in Python.\n\n#### `timeout(timeout)`\n\noverrides the timeout parameter of the module\n\n* **Parameters:**\n  **timeout** (*float*)\n* **Return type:**\n  *Query*\n\n#### `verbatim()`\n\nSet the query to be verbatim, i.e., use no query expansion\nor stemming.\n\n* **Return type:**\n  *Query*\n\n#### `with_payloads()`\n\nAsk the engine to return document payloads.\n\n* **Return type:**\n  *Query*\n\n#### `with_scores()`\n\nAsk the engine to return document search scores.\n\n* **Return type:**\n  *Query*\n\n#### `property batch_size: int | None`\n\nReturn the batch size for the query.\n\n* **Returns:**\n  The batch size for the query.\n* **Return type:**\n  Optional[int]\n\n#### `property ef_runtime: int | None`\n\nReturn the EF_RUNTIME parameter for the query.\n\n* **Returns:**\n  The EF_RUNTIME value for the query.\n* **Return type:**\n  Optional[int]\n\n#### `property epsilon: float | None`\n\nReturn the epsilon parameter for the query.\n\n* **Returns:**\n  The epsilon value for the query.\n* **Return type:**\n  Optional[float]\n\n#### `property filter: str | `[`FilterExpression`](https://redis.io/docs/latest/filter/#filterexpression)` `\n\nThe filter expression for the query.\n\n#### `property hybrid_policy: str | None`\n\nReturn the hybrid policy for the query.\n\n* **Returns:**\n  The hybrid policy for the query.\n* **Return type:**\n  Optional[str]\n\n#### `property params: Dict[str, Any]`\n\nReturn the parameters for the query.\n\n* **Returns:**\n  The parameters for the query.\n* **Return type:**\n  Dict[str, Any]\n\n#### `property query: BaseQuery`\n\nReturn self as the query object.\n\n#### `property search_buffer_capacity: int | None`\n\nReturn the SEARCH_BUFFER_CAPACITY parameter for the query.\n\n* **Returns:**\n  The SEARCH_BUFFER_CAPACITY value for the query.\n* **Return type:**\n  Optional[int]\n\n#### `property search_window_size: int | None`\n\nReturn the SEARCH_WINDOW_SIZE parameter for the query.\n\n* **Returns:**\n  The SEARCH_WINDOW_SIZE value for the query.\n* **Return type:**\n  Optional[int]\n\n#### `property use_search_history: str | None`\n\nReturn the USE_SEARCH_HISTORY parameter for the query.\n\n* **Returns:**\n  The USE_SEARCH_HISTORY value for the query.\n* **Return type:**\n  Optional[str]\n\n#### `NOTE`\n**Runtime Parameters for Performance Tuning**\n\nVectorQuery supports runtime parameters for HNSW and SVS-VAMANA indexes that can be adjusted at query time without rebuilding the index:\n\n**HNSW Parameters:**\n\n- `ef_runtime`: Controls search accuracy (higher = better recall, slower search)\n\n**SVS-VAMANA Parameters:**\n\n- `search_window_size`: Size of search window for KNN searches\n- `use_search_history`: Whether to use search buffer (OFF/ON/AUTO)\n- `search_buffer_capacity`: Tuning parameter for 2-level compression\n\nExample with HNSW runtime parameters:\n\n```python\nfrom redisvl.query import VectorQuery\n\nquery = VectorQuery(\n    vector=[0.1, 0.2, 0.3],\n    vector_field_name=\"embedding\",\n    num_results=10,\n    ef_runtime=150  # Higher for better recall\n)\n```\n\nExample with SVS-VAMANA runtime parameters:\n\n```python\nquery = VectorQuery(\n    vector=[0.1, 0.2, 0.3],\n    vector_field_name=\"embedding\",\n    num_results=10,\n    search_window_size=20,\n    use_search_history='ON',\n    search_buffer_capacity=30\n)\n```\n\n## VectorRangeQuery\n\n### `class VectorRangeQuery(vector, vector_field_name, return_fields=None, filter_expression=None, dtype='float32', distance_threshold=0.2, epsilon=None, search_window_size=None, use_search_history=None, search_buffer_capacity=None, num_results=10, return_score=True, dialect=2, sort_by=None, in_order=False, hybrid_policy=None, batch_size=None, normalize_vector_distance=False)`\n\nBases: `BaseVectorQuery`, `BaseQuery`\n\nA query for running a filtered vector search based on semantic\ndistance threshold.\n\n* **Parameters:**\n  * **vector** (*List* *[* *float* *]*) – The vector to perform the range query with.\n  * **vector_field_name** (*str*) – The name of the vector field to search\n    against in the database.\n  * **return_fields** (*List* *[* *str* *]*) – The declared fields to return with search\n    results.\n  * **filter_expression** (*Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *,* *optional*) – A filter to apply\n    along with the range query. Defaults to None.\n  * **dtype** (*str* *,* *optional*) – The dtype of the vector. Defaults to\n    \"float32\".\n  * **distance_threshold** (*float*) – The threshold for vector distance.\n    A smaller threshold indicates a stricter semantic search.\n    Defaults to 0.2.\n  * **epsilon** (*Optional* *[* *float* *]*) – The relative factor for vector range queries,\n    setting boundaries for candidates within radius \\* (1 + epsilon).\n    This controls how extensive the search is beyond the specified radius.\n    Higher values increase recall at the expense of performance.\n    Defaults to None, which uses the index-defined epsilon (typically 0.01).\n  * **search_window_size** (*Optional* *[* *int* *]*) – The size of the search window for SVS-VAMANA range searches.\n    Increasing this value generally yields more accurate but slower search results.\n    Defaults to None, which uses the index-defined value (typically 10).\n  * **use_search_history** (*Optional* *[* *str* *]*) – For SVS-VAMANA indexes, controls whether to use the\n    search buffer or entire search history. Options are \"OFF\", \"ON\", or \"AUTO\".\n    \"AUTO\" is always evaluated internally as \"ON\". Using the entire history may yield\n    a slightly better graph at the cost of more search time.\n    Defaults to None, which uses the index-defined value (typically \"AUTO\").\n  * **search_buffer_capacity** (*Optional* *[* *int* *]*) – Tuning parameter for SVS-VAMANA indexes using\n    two-level compression (LVQ\u003cX\u003ex\u003cY\u003e or LeanVec types). Determines the number of vector\n    candidates to collect in the first level of search before the re-ranking level.\n    Defaults to None, which uses the index-defined value (typically SEARCH_WINDOW_SIZE).\n  * **num_results** (*int*) – The MAX number of results to return.\n    Defaults to 10.\n  * **return_score** (*bool* *,* *optional*) – Whether to return the vector\n    distance. Defaults to True.\n  * **dialect** (*int* *,* *optional*) – The RediSearch query dialect.\n    Defaults to 2.\n  * **sort_by** (*Optional* *[* *SortSpec* *]*) – The field(s) to order the results by. Can be:\n    - str: single field name\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\")\n    - List: list of fields or tuples\n    Note: Only the first field is used for Redis sorting.\n    Defaults to None. Results will be ordered by vector distance.\n  * **in_order** (*bool*) – Requires the terms in the field to have\n    the same order as the terms in the query filter, regardless of\n    the offsets between them. Defaults to False.\n  * **hybrid_policy** (*Optional* *[* *str* *]*) – Controls how filters are applied during vector search.\n    Options are \"BATCHES\" (paginates through small batches of nearest neighbors) or\n    \"ADHOC_BF\" (computes scores for all vectors passing the filter).\n    \"BATCHES\" mode is typically faster for queries with selective filters.\n    \"ADHOC_BF\" mode is better when filters match a large portion of the dataset.\n    Defaults to None, which lets Redis auto-select the optimal policy.\n  * **batch_size** (*Optional* *[* *int* *]*) – When hybrid_policy is \"BATCHES\", controls the number\n    of vectors to fetch in each batch. Larger values may improve performance\n    at the cost of memory usage. Only applies when hybrid_policy=\"BATCHES\".\n    Defaults to None, which lets Redis auto-select an appropriate batch size.\n  * **normalize_vector_distance** (*bool*) – Redis supports 3 distance metrics: L2 (euclidean),\n    IP (inner product), and COSINE. By default, L2 distance returns an unbounded value.\n    COSINE distance returns a value between 0 and 2. IP returns a value determined by\n    the magnitude of the vector. Setting this flag to true converts COSINE and L2 distance\n    to a similarity score between 0 and 1. Note: setting this flag to true for IP will\n    throw a warning since by definition COSINE similarity is normalized IP.\n* **Raises:**\n  **TypeError** – If filter_expression is not of type redisvl.query.FilterExpression\n\n#### `NOTE`\nLearn more about vector range queries: [https://redis.io/docs/interact/search-and-query/search/vectors/#range-query](https://redis.io/docs/interact/search-and-query/search/vectors/#range-query)\n\n#### `dialect(dialect)`\n\nAdd a dialect field to the query.\n\n- **dialect** - dialect version to execute the query under\n\n* **Parameters:**\n  **dialect** (*int*)\n* **Return type:**\n  *Query*\n\n#### `expander(expander)`\n\nAdd an expander field to the query.\n\n- **expander** - the name of the expander\n\n* **Parameters:**\n  **expander** (*str*)\n* **Return type:**\n  *Query*\n\n#### `in_order()`\n\nMatch only documents where the query terms appear in\nthe same order in the document.\ni.e., for the query \"hello world\", we do not match \"world hello\"\n\n* **Return type:**\n  *Query*\n\n#### `language(language)`\n\nAnalyze the query as being in the specified language.\n\n* **Parameters:**\n  **language** (*str*) – The language (e.g. chinese or english)\n* **Return type:**\n  *Query*\n\n#### `limit_fields(*fields)`\n\nLimit the search to specific TEXT fields only.\n\n- **fields**: Each element should be a string, case sensitive field name\n\nfrom the defined schema.\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *Query*\n\n#### `limit_ids(*ids)`\n\nLimit the results to a specific set of pre-known document\nids of any length.\n\n* **Return type:**\n  *Query*\n\n#### `no_content()`\n\nSet the query to only return ids and not the document content.\n\n* **Return type:**\n  *Query*\n\n#### `no_stopwords()`\n\nPrevent the query from being filtered for stopwords.\nOnly useful in very big queries that you are certain contain\nno stopwords.\n\n* **Return type:**\n  *Query*\n\n#### `paging(offset, num)`\n\nSet the paging for the query (defaults to 0..10).\n\n- **offset**: Paging offset for the results. Defaults to 0\n- **num**: How many results do we want\n\n* **Parameters:**\n  * **offset** (*int*)\n  * **num** (*int*)\n* **Return type:**\n  *Query*\n\n#### `query_string()`\n\nReturn the query string of this query only.\n\n* **Return type:**\n  str\n\n#### `return_fields(*fields, skip_decode=None)`\n\nSet the fields to return with search results.\n\n* **Parameters:**\n  * **\\*fields** – Variable number of field names to return.\n  * **skip_decode** (*List* *[* *str* *]*  *|* *str* *|* *None*) – Optional field name or list of field names that should not be\n    decoded. Useful for binary data like embeddings.\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  **TypeError** – If skip_decode is not a string, list, or None.\n\n#### `scorer(scorer)`\n\nUse a different scoring function to evaluate document relevance.\nDefault is TFIDF.\n\nSince Redis 8.0 default was changed to BM25STD.\n\n* **Parameters:**\n  **scorer** (*str*) – The scoring function to use\n  (e.g. TFIDF.DOCNORM or BM25)\n* **Return type:**\n  *Query*\n\n#### `set_batch_size(batch_size)`\n\nSet the batch size for the query.\n\n* **Parameters:**\n  **batch_size** (*int*) – The batch size to use when hybrid_policy is \"BATCHES\".\n* **Raises:**\n  * **TypeError** – If batch_size is not an integer\n  * **ValueError** – If batch_size is not positive\n\n#### `set_distance_threshold(distance_threshold)`\n\nSet the distance threshold for the query.\n\n* **Parameters:**\n  **distance_threshold** (*float*) – Vector distance threshold.\n* **Raises:**\n  * **TypeError** – If distance_threshold is not a float or int\n  * **ValueError** – If distance_threshold is negative\n\n#### `set_epsilon(epsilon)`\n\nSet the epsilon parameter for the range query.\n\n* **Parameters:**\n  **epsilon** (*float*) – The relative factor for vector range queries,\n  setting boundaries for candidates within radius \\* (1 + epsilon).\n* **Raises:**\n  * **TypeError** – If epsilon is not a float or int\n  * **ValueError** – If epsilon is negative\n\n#### `set_filter(filter_expression=None)`\n\nSet the filter expression for the query.\n\n* **Parameters:**\n  **filter_expression** (*Optional* *[* *Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *]* *,* *optional*) – The filter\n  expression or query string to use on the query.\n* **Raises:**\n  **TypeError** – If filter_expression is not a valid FilterExpression or string.\n\n#### `set_hybrid_policy(hybrid_policy)`\n\nSet the hybrid policy for the query.\n\n* **Parameters:**\n  **hybrid_policy** (*str*) – The hybrid policy to use. Options are \"BATCHES\"\n  or \"ADHOC_BF\".\n* **Raises:**\n  **ValueError** – If hybrid_policy is not one of the valid options\n\n#### `set_search_buffer_capacity(search_buffer_capacity)`\n\nSet the SEARCH_BUFFER_CAPACITY parameter for the range query.\n\n* **Parameters:**\n  **search_buffer_capacity** (*int*) – Tuning parameter for SVS-VAMANA indexes using\n  two-level compression.\n* **Raises:**\n  * **TypeError** – If search_buffer_capacity is not an integer\n  * **ValueError** – If search_buffer_capacity is not positive\n\n#### `set_search_window_size(search_window_size)`\n\nSet the SEARCH_WINDOW_SIZE parameter for the range query.\n\n* **Parameters:**\n  **search_window_size** (*int*) – The size of the search window for SVS-VAMANA range searches.\n* **Raises:**\n  * **TypeError** – If search_window_size is not an integer\n  * **ValueError** – If search_window_size is not positive\n\n#### `set_use_search_history(use_search_history)`\n\nSet the USE_SEARCH_HISTORY parameter for the range query.\n\n* **Parameters:**\n  **use_search_history** (*str*) – Controls whether to use the search buffer or entire history.\n  Must be one of \"OFF\", \"ON\", or \"AUTO\".\n* **Raises:**\n  * **TypeError** – If use_search_history is not a string\n  * **ValueError** – If use_search_history is not one of the valid options\n\n#### `slop(slop)`\n\nAllow a maximum of N intervening non-matched terms between\nphrase terms (0 means exact phrase).\n\n* **Parameters:**\n  **slop** (*int*)\n* **Return type:**\n  *Query*\n\n#### `sort_by(sort_spec=None, asc=True)`\n\nSet the sort order for query results.\n\nThis method supports sorting by single or multiple fields. Note that Redis Search\nnatively supports only a single SORTBY field. When multiple fields are specified,\nonly the FIRST field is used for the Redis SORTBY clause.\n\n* **Parameters:**\n  * **sort_spec** (*str* *|* *Tuple* *[* *str* *,* *str* *]*  *|* *List* *[* *str* *|* *Tuple* *[* *str* *,* *str* *]* *]*  *|* *None*) – Sort specification in various formats:\n    - str: single field name\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\")\n    - List: list of field names or tuples\n  * **asc** (*bool*) – Default sort direction when not specified (only used when sort_spec is a string).\n    Defaults to True (ascending).\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  * **TypeError** – If sort_spec is not a valid type.\n  * **ValueError** – If direction is not \"ASC\" or \"DESC\".\n\n### `Examples`\n\n```pycon\n\u003e\u003e query.sort_by(\"price\")  # Single field, ascending\n\u003e\u003e query.sort_by((\"price\", \"DESC\"))  # Single field, descending\n\u003e\u003e query.sort_by([\"price\", \"rating\"])  # Multiple fields (only first used)\n\u003e\u003e query.sort_by([(\"price\", \"DESC\"), (\"rating\", \"ASC\")])\n```\n\n#### `NOTE`\nWhen multiple fields are specified, only the first field is used for sorting\nin Redis. Future versions may support multi-field sorting through post-query\nsorting in Python.\n\n#### `timeout(timeout)`\n\noverrides the timeout parameter of the module\n\n* **Parameters:**\n  **timeout** (*float*)\n* **Return type:**\n  *Query*\n\n#### `verbatim()`\n\nSet the query to be verbatim, i.e., use no query expansion\nor stemming.\n\n* **Return type:**\n  *Query*\n\n#### `with_payloads()`\n\nAsk the engine to return document payloads.\n\n* **Return type:**\n  *Query*\n\n#### `with_scores()`\n\nAsk the engine to return document search scores.\n\n* **Return type:**\n  *Query*\n\n#### `property batch_size: int | None`\n\nReturn the batch size for the query.\n\n* **Returns:**\n  The batch size for the query.\n* **Return type:**\n  Optional[int]\n\n#### `property distance_threshold: float`\n\nReturn the distance threshold for the query.\n\n* **Returns:**\n  The distance threshold for the query.\n* **Return type:**\n  float\n\n#### `property epsilon: float | None`\n\nReturn the epsilon for the query.\n\n* **Returns:**\n  The epsilon for the query, or None if not set.\n* **Return type:**\n  Optional[float]\n\n#### `property filter: str | `[`FilterExpression`](https://redis.io/docs/latest/filter/#filterexpression)` `\n\nThe filter expression for the query.\n\n#### `property hybrid_policy: str | None`\n\nReturn the hybrid policy for the query.\n\n* **Returns:**\n  The hybrid policy for the query.\n* **Return type:**\n  Optional[str]\n\n#### `property params: Dict[str, Any]`\n\nReturn the parameters for the query.\n\n* **Returns:**\n  The parameters for the query.\n* **Return type:**\n  Dict[str, Any]\n\n#### `property query: BaseQuery`\n\nReturn self as the query object.\n\n#### `property search_buffer_capacity: int | None`\n\nReturn the SEARCH_BUFFER_CAPACITY parameter for the query.\n\n* **Returns:**\n  The SEARCH_BUFFER_CAPACITY value for the query.\n* **Return type:**\n  Optional[int]\n\n#### `property search_window_size: int | None`\n\nReturn the SEARCH_WINDOW_SIZE parameter for the query.\n\n* **Returns:**\n  The SEARCH_WINDOW_SIZE value for the query.\n* **Return type:**\n  Optional[int]\n\n#### `property use_search_history: str | None`\n\nReturn the USE_SEARCH_HISTORY parameter for the query.\n\n* **Returns:**\n  The USE_SEARCH_HISTORY value for the query.\n* **Return type:**\n  Optional[str]\n\n#### `NOTE`\n**Runtime Parameters for Range Queries**\n\nVectorRangeQuery supports runtime parameters for controlling range search behavior:\n\n**HNSW \u0026 SVS-VAMANA Parameters:**\n\n- `epsilon`: Range search approximation factor (default: 0.01)\n\n**SVS-VAMANA Parameters:**\n\n- `search_window_size`: Size of search window\n- `use_search_history`: Whether to use search buffer (OFF/ON/AUTO)\n- `search_buffer_capacity`: Tuning parameter for 2-level compression\n\nExample:\n\n```python\nfrom redisvl.query import VectorRangeQuery\n\nquery = VectorRangeQuery(\n    vector=[0.1, 0.2, 0.3],\n    vector_field_name=\"embedding\",\n    distance_threshold=0.3,\n    epsilon=0.05,              # Approximation factor\n    search_window_size=20,     # SVS-VAMANA only\n    use_search_history='AUTO'  # SVS-VAMANA only\n)\n```\n\n## AggregateHybridQuery\n\n### `class AggregateHybridQuery(text, text_field_name, vector, vector_field_name, text_scorer='BM25STD', filter_expression=None, alpha=0.7, dtype='float32', num_results=10, return_fields=None, stopwords='english', dialect=2, text_weights=None)`\n\nBases: `AggregationQuery`\n\nAggregateHybridQuery combines text and vector search in Redis.\nIt allows you to perform a hybrid search using both text and vector similarity.\nIt scores documents based on a weighted combination of text and vector similarity.\n\n```python\nfrom redisvl.query import AggregateHybridQuery\nfrom redisvl.index import SearchIndex\n\nindex = SearchIndex.from_yaml(\"path/to/index.yaml\")\n\nquery = AggregateHybridQuery(\n    text=\"example text\",\n    text_field_name=\"text_field\",\n    vector=[0.1, 0.2, 0.3],\n    vector_field_name=\"vector_field\",\n    text_scorer=\"BM25STD\",\n    filter_expression=None,\n    alpha=0.7,\n    dtype=\"float32\",\n    num_results=10,\n    return_fields=[\"field1\", \"field2\"],\n    stopwords=\"english\",\n    dialect=2,\n)\n\nresults = index.query(query)\n```\n\nInstantiates a AggregateHybridQuery object.\n\n* **Parameters:**\n  * **text** (*str*) – The text to search for.\n  * **text_field_name** (*str*) – The text field name to search in.\n  * **vector** (*Union* *[* *bytes* *,* *List* *[* *float* *]* *]*) – The vector to perform vector similarity search.\n  * **vector_field_name** (*str*) – The vector field name to search in.\n  * **text_scorer** (*str* *,* *optional*) – The text scorer to use. Options are {TFIDF, TFIDF.DOCNORM,\n    BM25, DISMAX, DOCSCORE, BM25STD}. Defaults to \"BM25STD\".\n  * **filter_expression** (*Optional* *[*[*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *,* *optional*) – The filter expression to use.\n    Defaults to None.\n  * **alpha** (*float* *,* *optional*) – The weight of the vector similarity. Documents will be scored\n    as: hybrid_score = (alpha) \\* vector_score + (1-alpha) \\* text_score.\n    Defaults to 0.7.\n  * **dtype** (*str* *,* *optional*) – The data type of the vector. Defaults to \"float32\".\n  * **num_results** (*int* *,* *optional*) – The number of results to return. Defaults to 10.\n  * **return_fields** (*Optional* *[* *List* *[* *str* *]* *]* *,* *optional*) – The fields to return. Defaults to None.\n  * **stopwords** (*Optional* *[* *Union* *[* *str* *,* *Set* *[* *str* *]* *]* *]* *,* *optional*) – \n\n    The stopwords to remove from the\n    provided text prior to search-use. If a string such as \"english\" \"german\" is\n    provided then a default set of stopwords for that language will be used. if a list,\n    set, or tuple of strings is provided then those will be used as stopwords.\n    Defaults to \"english\". if set to \"None\" then no stopwords will be removed.\n\n    Note: This parameter controls query-time stopword filtering (client-side).\n    For index-level stopwords configuration (server-side), see IndexInfo.stopwords.\n    Using query-time stopwords with index-level STOPWORDS 0 is counterproductive.\n  * **dialect** (*int* *,* *optional*) – The Redis dialect version. Defaults to 2.\n  * **text_weights** (*Optional* *[* *Dict* *[* *str* *,* *float* *]* *]*) – The importance weighting of individual words\n    within the query text. Defaults to None, as no modifications will be made to the\n    text_scorer score.\n\n#### `NOTE`\nAggregateHybridQuery uses FT.AGGREGATE commands which do NOT support runtime\nparameters. For runtime parameter support (ef_runtime, search_window_size, etc.),\nuse VectorQuery or VectorRangeQuery which use FT.SEARCH commands.\n\n* **Raises:**\n  * **ValueError** – If the text string is empty, or if the text string becomes empty after\n        stopwords are removed.\n  * **TypeError** – If the stopwords are not a set, list, or tuple of strings.\n* **Parameters:**\n  * **text** (*str*)\n  * **text_field_name** (*str*)\n  * **vector** (*bytes* *|* *List* *[* *float* *]*)\n  * **vector_field_name** (*str*)\n  * **text_scorer** (*str*)\n  * **filter_expression** (*str* *|* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *|* *None*)\n  * **alpha** (*float*)\n  * **dtype** (*str*)\n  * **num_results** (*int*)\n  * **return_fields** (*List* *[* *str* *]*  *|* *None*)\n  * **stopwords** (*str* *|* *Set* *[* *str* *]*  *|* *None*)\n  * **dialect** (*int*)\n  * **text_weights** (*Dict* *[* *str* *,* *float* *]*  *|* *None*)\n\n#### `add_scores()`\n\nIf set, includes the score as an ordinary field of the row.\n\n* **Return type:**\n  *AggregateRequest*\n\n#### `apply(**kwexpr)`\n\nSpecify one or more projection expressions to add to each result\n\n### `Parameters`\n\n- **kwexpr**: One or more key-value pairs for a projection. The key is\n  : the alias for the projection, and the value is the projection\n    expression itself, for example apply(square_root=\"sqrt(@foo)\")\n\n* **Return type:**\n  *AggregateRequest*\n\n#### `dialect(dialect)`\n\nAdd a dialect field to the aggregate command.\n\n- **dialect** - dialect version to execute the query under\n\n* **Parameters:**\n  **dialect** (*int*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `filter(expressions)`\n\nSpecify filter for post-query results using predicates relating to\nvalues in the result set.\n\n### `Parameters`\n\n- **fields**: Fields to group by. This can either be a single string,\n  : or a list of strings.\n\n* **Parameters:**\n  **expressions** (*str* *|* *List* *[* *str* *]*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `group_by(fields, *reducers)`\n\nSpecify by which fields to group the aggregation.\n\n### `Parameters`\n\n- **fields**: Fields to group by. This can either be a single string,\n  : or a list of strings. both cases, the field should be specified as\n    @field.\n- **reducers**: One or more reducers. Reducers may be found in the\n  : aggregation module.\n\n* **Parameters:**\n  * **fields** (*str* *|* *List* *[* *str* *]*)\n  * **reducers** (*Reducer*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `limit(offset, num)`\n\nSets the limit for the most recent group or query.\n\nIf no group has been defined yet (via group_by()) then this sets\nthe limit for the initial pool of results from the query. Otherwise,\nthis limits the number of items operated on from the previous group.\n\nSetting a limit on the initial search results may be useful when\nattempting to execute an aggregation on a sample of a large data set.\n\n### `Parameters`\n\n- **offset**: Result offset from which to begin paging\n- **num**: Number of results to return\n\nExample of sorting the initial results:\n\n``\nAggregateRequest(\"@sale_amount:[10000, inf]\")            .limit(0, 10)            .group_by(\"@state\", r.count())\n``\n\nWill only group by the states found in the first 10 results of the\nquery @sale_amount:[10000, inf]. On the other hand,\n\n``\nAggregateRequest(\"@sale_amount:[10000, inf]\")            .limit(0, 1000)            .group_by(\"@state\", r.count()            .limit(0, 10)\n``\n\nWill group all the results matching the query, but only return the\nfirst 10 groups.\n\nIf you only wish to return a *top-N* style query, consider using\nsort_by() instead.\n\n* **Parameters:**\n  * **offset** (*int*)\n  * **num** (*int*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `load(*fields)`\n\nIndicate the fields to be returned in the response. These fields are\nreturned in addition to any others implicitly specified.\n\n### `Parameters`\n\n- **fields**: If fields not specified, all the fields will be loaded.\n\nOtherwise, fields should be given in the format of @field.\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `scorer(scorer)`\n\nUse a different scoring function to evaluate document relevance.\nDefault is TFIDF.\n\n* **Parameters:**\n  **scorer** (*str*) – The scoring function to use\n  (e.g. TFIDF.DOCNORM or BM25)\n* **Return type:**\n  *AggregateRequest*\n\n#### `set_text_weights(weights)`\n\nSet or update the text weights for the query.\n\n* **Parameters:**\n  **weights** (*Dict* *[* *str* *,* *float* *]*) – Dictionary of word:weight mappings\n\n#### `sort_by(*fields, **kwargs)`\n\nIndicate how the results should be sorted. This can also be used for\n*top-N* style queries\n\n### `Parameters`\n\n- **fields**: The fields by which to sort. This can be either a single\n  : field or a list of fields. If you wish to specify order, you can\n    use the Asc or Desc wrapper classes.\n- **max**: Maximum number of results to return. This can be\n  : used instead of LIMIT and is also faster.\n\nExample of sorting by foo ascending and bar descending:\n\n``\nsort_by(Asc(\"@foo\"), Desc(\"@bar\"))\n``\n\nReturn the top 10 customers:\n\n``\nAggregateRequest()            .group_by(\"@customer\", r.sum(\"@paid\").alias(FIELDNAME))            .sort_by(Desc(\"@paid\"), max=10)\n``\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `with_schema()`\n\nIf set, the schema property will contain a list of [field, type]\nentries in the result object.\n\n* **Return type:**\n  *AggregateRequest*\n\n#### `property params: Dict[str, Any]`\n\nReturn the parameters for the aggregation.\n\n* **Returns:**\n  The parameters for the aggregation.\n* **Return type:**\n  Dict[str, Any]\n\n#### `property stopwords: Set[str]`\n\nReturn the stopwords used in the query.\n:returns: The stopwords used in the query.\n:rtype: Set[str]\n\n#### `property text_weights: Dict[str, float]`\n\nGet the text weights.\n\n* **Returns:**\n  weight mappings.\n* **Return type:**\n  Dictionary of word\n\n#### `NOTE`\nThe `stopwords` parameter in [AggregateHybridQuery](#aggregatehybridquery) (and `HybridQuery`) controls query-time stopword filtering (client-side).\nFor index-level stopwords configuration (server-side), see `redisvl.schema.IndexInfo.stopwords`.\nUsing query-time stopwords with index-level `STOPWORDS 0` is counterproductive.\n\n#### `NOTE`\n`HybridQuery` and [AggregateHybridQuery](#aggregatehybridquery) apply linear combination inconsistently. `HybridQuery` uses `linear_alpha` to weight the text score, while [AggregateHybridQuery](#aggregatehybridquery) uses `alpha` to weight the vector score. When switching between the two classes, take care to revise your `alpha` setting.\n\n#### `NOTE`\n**Runtime Parameters for Hybrid Queries**\n\n**Important:** AggregateHybridQuery uses FT.AGGREGATE commands which do NOT support runtime parameters.\nRuntime parameters (`ef_runtime`, `search_window_size`, `use_search_history`, `search_buffer_capacity`)\nare only supported with FT.SEARCH commands.\n\nFor runtime parameter support, use `HybridQuery`, [VectorQuery](#vectorquery), or [VectorRangeQuery](#vectorrangequery) instead of AggregateHybridQuery.\n\nExample with HybridQuery (supports runtime parameters):\n\n```python\nfrom redisvl.query import HybridQuery\n\nquery = HybridQuery(\n    text=\"query string\",\n    text_field_name=\"description\",\n    vector=[0.1, 0.2, 0.3],\n    vector_field_name=\"embedding\",\n    vector_search_method=\"KNN\",\n    knn_ef_runtime=150,  # Runtime parameters work with HybridQuery\n    return_fields=[\"description\"],\n    num_results=10,\n)\n```\n\n## HybridQuery\n\n### `class HybridQuery(text, text_field_name, vector, vector_field_name, vector_param_name='vector', text_scorer='BM25STD', yield_text_score_as=None, vector_search_method=None, knn_ef_runtime=10, range_radius=None, range_epsilon=0.01, yield_vsim_score_as=None, filter_expression=None, combination_method=None, rrf_window=20, rrf_constant=60, linear_alpha=0.3, yield_combined_score_as=None, dtype='float32', num_results=10, return_fields=None, stopwords='english', text_weights=None)`\n\nBases: `object`\n\nA hybrid search query that combines text search and vector similarity, with configurable fusion methods.\n\n```python\nfrom redisvl.query import HybridQuery\nfrom redisvl.index import SearchIndex\n\nindex = SearchIndex.from_yaml(\"path/to/index.yaml\")\n\nquery = HybridQuery(\n    text=\"example text\",\n    text_field_name=\"text_field\",\n    vector=[0.1, 0.2, 0.3],\n    vector_field_name=\"vector_field\",\n    text_scorer=\"BM25STD\",\n    yield_text_score_as=\"text_score\",\n    yield_vsim_score_as=\"vector_similarity\",\n    combination_method=\"LINEAR\",\n    linear_alpha=0.3,\n    yield_combined_score_as=\"hybrid_score\",\n    num_results=10,\n    return_fields=[\"field1\", \"field2\"],\n    stopwords=\"english\",\n)\n\nresults = index.query(query)\n```\n\n#### `SEE ALSO`\n- [FT.HYBRID command documentation](https://redis.io/docs/latest/commands/ft.hybrid)\n- [redis-py hybrid_search documentation](https://redis.readthedocs.io/en/stable/redismodules.html#redis.commands.search.commands.SearchCommands.hybrid_search)\n\nInstantiates a HybridQuery object.\n\n* **Parameters:**\n  * **text** (*str*) – The text to search for.\n  * **text_field_name** (*str*) – The text field name to search in.\n  * **vector** (*bytes* *|* *List* *[* *float* *]*) – The vector to perform vector similarity search.\n  * **vector_field_name** (*str*) – The vector field name to search in.\n  * **vector_param_name** (*str*) – The name of the parameter substitution containing the vector blob.\n  * **text_scorer** (*str*) – The text scorer to use. Options are {TFIDF, TFIDF.DOCNORM,\n    BM25STD, BM25STD.NORM, BM25STD.TANH, DISMAX, DOCSCORE, HAMMING}. Defaults to \"BM25STD\". For more\n    information about supported scoring algorithms,\n    see [https://redis.io/docs/latest/develop/ai/search-and-query/advanced-concepts/scoring/](https://redis.io/docs/latest/develop/ai/search-and-query/advanced-concepts/scoring/)\n  * **yield_text_score_as** (*str* *|* *None*) – The name of the field to yield the text score as.\n  * **vector_search_method** (*Literal* *[* *'KNN'* *,*  *'RANGE'* *]*  *|* *None*) – The vector search method to use. Options are {KNN, RANGE}. Defaults to None.\n  * **knn_ef_runtime** (*int*) – The exploration factor parameter for HNSW, optional if vector_search_method is \"KNN\".\n  * **range_radius** (*float* *|* *None*) – The search radius to use, required if vector_search_method is \"RANGE\".\n  * **range_epsilon** (*float*) – The epsilon value to use, optional if vector_search_method is \"RANGE\"; defines the\n    accuracy of the search.\n  * **yield_vsim_score_as** (*str* *|* *None*) – The name of the field to yield the vector similarity score as.\n  * **filter_expression** (*str* *|* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *|* *None*) – The filter expression to use for both the text and vector searches. Defaults to None.\n  * **combination_method** (*Literal* *[* *'RRF'* *,*  *'LINEAR'* *]*  *|* *None*) – The combination method to use. Options are {RRF, LINEAR}. If not specified, the server\n    defaults to RRF. If \"RRF\" is specified, then at least one of rrf_window or rrf_constant must be\n    provided. If \"LINEAR\" is specified, then at least one of linear_alpha or linear_beta must be\n    provided.\n  * **rrf_window** (*int*) – The window size to use for the reciprocal rank fusion (RRF) combination method. Limits\n    fusion scope.\n  * **rrf_constant** (*int*) – The constant to use for the reciprocal rank fusion (RRF) combination method. Controls decay\n    of rank influence.\n  * **linear_alpha** (*float*) – The weight of the text query for the linear combination method (LINEAR).\n  * **yield_combined_score_as** (*str* *|* *None*) – The name of the field to yield the combined score as.\n  * **dtype** (*str*) – The data type of the vector. Defaults to \"float32\".\n  * **num_results** (*int* *|* *None*) – The number of results to return.\n  * **return_fields** (*List* *[* *str* *]*  *|* *None*) – The fields to return. Defaults to None.\n  * **stopwords** (*Optional* *[* *Union* *[* *str* *,* *Set* *[* *str* *]* *]* *]* *,* *optional*) – \n\n    The stopwords to remove from the\n    provided text prior to search-use. If a string such as \"english\" \"german\" is\n    provided then a default set of stopwords for that language will be used. if a list,\n    set, or tuple of strings is provided then those will be used as stopwords.\n    Defaults to \"english\". if set to \"None\" then no stopwords will be removed.\n\n    Note: This parameter controls query-time stopword filtering (client-side).\n    For index-level stopwords configuration (server-side), see IndexInfo.stopwords.\n    Using query-time stopwords with index-level STOPWORDS 0 is counterproductive.\n  * **text_weights** (*Optional* *[* *Dict* *[* *str* *,* *float* *]* *]*) – The importance weighting of individual words\n    within the query text. Defaults to None, as no modifications will be made to the\n    text_scorer score.\n* **Raises:**\n  * **ImportError** – If redis-py\u003e=7.1.0 is not installed.\n  * **TypeError** – If the stopwords are not a set, list, or tuple of strings.\n  * **ValueError** – If the text string is empty, or if the text string becomes empty after\n        stopwords are removed.\n  * **ValueError** – If vector_search_method is defined and isn’t one of {KNN, RANGE}.\n  * **ValueError** – If vector_search_method is \"KNN\" and knn_k is not provided.\n  * **ValueError** – If vector_search_method is \"RANGE\" and range_radius is not provided.\n\n#### `NOTE`\nThe `stopwords` parameter in [HybridQuery](#hybridquery) (and `AggregateHybridQuery`) controls query-time stopword filtering (client-side).\nFor index-level stopwords configuration (server-side), see `redisvl.schema.IndexInfo.stopwords`.\nUsing query-time stopwords with index-level `STOPWORDS 0` is counterproductive.\n\n#### `NOTE`\n[HybridQuery](#hybridquery) and `AggregateHybridQuery` apply linear combination inconsistently. [HybridQuery](#hybridquery) uses `linear_alpha` to weight the text score, while `AggregateHybridQuery` uses `alpha` to weight the vector score. When switching between the two classes, take care to revise your `alpha` setting.\n\n## TextQuery\n\n### `class TextQuery(text, text_field_name, text_scorer='BM25STD', filter_expression=None, return_fields=None, num_results=10, return_score=True, dialect=2, sort_by=None, in_order=False, params=None, stopwords='english', text_weights=None)`\n\nBases: `BaseQuery`\n\nTextQuery is a query for running a full text search, along with an optional filter expression.\n\n```python\nfrom redisvl.query import TextQuery\nfrom redisvl.index import SearchIndex\n\nindex = SearchIndex.from_yaml(index.yaml)\n\nquery = TextQuery(\n    text=\"example text\",\n    text_field_name=\"text_field\",\n    text_scorer=\"BM25STD\",\n    filter_expression=None,\n    num_results=10,\n    return_fields=[\"field1\", \"field2\"],\n    stopwords=\"english\",\n    dialect=2,\n)\n\nresults = index.query(query)\n```\n\nA query for running a full text search, along with an optional filter expression.\n\n* **Parameters:**\n  * **text** (*str*) – The text string to perform the text search with.\n  * **text_field_name** (*Union* *[* *str* *,* *Dict* *[* *str* *,* *float* *]* *]*) – The name of the document field to perform\n    text search on, or a dictionary mapping field names to their weights.\n  * **text_scorer** (*str* *,* *optional*) – The text scoring algorithm to use.\n    Defaults to BM25STD. Options are {TFIDF, BM25STD, BM25, TFIDF.DOCNORM, DISMAX, DOCSCORE}.\n    See [https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/scoring/](https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/scoring/)\n  * **filter_expression** (*Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *,* *optional*) – A filter to apply\n    along with the text search. Defaults to None.\n  * **return_fields** (*List* *[* *str* *]*) – The declared fields to return with search\n    results.\n  * **num_results** (*int* *,* *optional*) – The top k results to return from the\n    search. Defaults to 10.\n  * **return_score** (*bool* *,* *optional*) – Whether to return the text score.\n    Defaults to True.\n  * **dialect** (*int* *,* *optional*) – The RediSearch query dialect.\n    Defaults to 2.\n  * **sort_by** (*Optional* *[* *SortSpec* *]*) – The field(s) to order the results by. Can be:\n    - str: single field name\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\")\n    - List: list of fields or tuples\n    Note: Only the first field is used for Redis sorting.\n    Defaults to None. Results will be ordered by text score.\n  * **in_order** (*bool*) – Requires the terms in the field to have\n    the same order as the terms in the query filter, regardless of\n    the offsets between them. Defaults to False.\n  * **params** (*Optional* *[* *Dict* *[* *str* *,* *Any* *]* *]* *,* *optional*) – The parameters for the query.\n    Defaults to None.\n  * **stopwords** (*Optional* *[* *Union* *[* *str* *,* *Set* *[* *str* *]* *]*) – \n\n    The set of stop words to remove\n    from the query text (client-side filtering). If a language like ‘english’ or ‘spanish’ is provided\n    a default set of stopwords for that language will be used. Users may specify\n    their own stop words by providing a List or Set of words. if set to None,\n    then no words will be removed. Defaults to ‘english’.\n\n    Note: This parameter controls query-time stopword filtering (client-side).\n    For index-level stopwords configuration (server-side), see IndexInfo.stopwords.\n    Using query-time stopwords with index-level STOPWORDS 0 is counterproductive.\n  * **text_weights** (*Optional* *[* *Dict* *[* *str* *,* *float* *]* *]*) – The importance weighting of individual words\n    within the query text. Defaults to None, as no modifications will be made to the\n    text_scorer score.\n* **Raises:**\n  * **ValueError** – if stopwords language string cannot be loaded.\n  * **TypeError** – If stopwords is not a valid iterable set of strings.\n\n#### `dialect(dialect)`\n\nAdd a dialect field to the query.\n\n- **dialect** - dialect version to execute the query under\n\n* **Parameters:**\n  **dialect** (*int*)\n* **Return type:**\n  *Query*\n\n#### `expander(expander)`\n\nAdd an expander field to the query.\n\n- **expander** - the name of the expander\n\n* **Parameters:**\n  **expander** (*str*)\n* **Return type:**\n  *Query*\n\n#### `in_order()`\n\nMatch only documents where the query terms appear in\nthe same order in the document.\ni.e., for the query \"hello world\", we do not match \"world hello\"\n\n* **Return type:**\n  *Query*\n\n#### `language(language)`\n\nAnalyze the query as being in the specified language.\n\n* **Parameters:**\n  **language** (*str*) – The language (e.g. chinese or english)\n* **Return type:**\n  *Query*\n\n#### `limit_fields(*fields)`\n\nLimit the search to specific TEXT fields only.\n\n- **fields**: Each element should be a string, case sensitive field name\n\nfrom the defined schema.\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *Query*\n\n#### `limit_ids(*ids)`\n\nLimit the results to a specific set of pre-known document\nids of any length.\n\n* **Return type:**\n  *Query*\n\n#### `no_content()`\n\nSet the query to only return ids and not the document content.\n\n* **Return type:**\n  *Query*\n\n#### `no_stopwords()`\n\nPrevent the query from being filtered for stopwords.\nOnly useful in very big queries that you are certain contain\nno stopwords.\n\n* **Return type:**\n  *Query*\n\n#### `paging(offset, num)`\n\nSet the paging for the query (defaults to 0..10).\n\n- **offset**: Paging offset for the results. Defaults to 0\n- **num**: How many results do we want\n\n* **Parameters:**\n  * **offset** (*int*)\n  * **num** (*int*)\n* **Return type:**\n  *Query*\n\n#### `query_string()`\n\nReturn the query string of this query only.\n\n* **Return type:**\n  str\n\n#### `return_fields(*fields, skip_decode=None)`\n\nSet the fields to return with search results.\n\n* **Parameters:**\n  * **\\*fields** – Variable number of field names to return.\n  * **skip_decode** (*List* *[* *str* *]*  *|* *str* *|* *None*) – Optional field name or list of field names that should not be\n    decoded. Useful for binary data like embeddings.\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  **TypeError** – If skip_decode is not a string, list, or None.\n\n#### `scorer(scorer)`\n\nUse a different scoring function to evaluate document relevance.\nDefault is TFIDF.\n\nSince Redis 8.0 default was changed to BM25STD.\n\n* **Parameters:**\n  **scorer** (*str*) – The scoring function to use\n  (e.g. TFIDF.DOCNORM or BM25)\n* **Return type:**\n  *Query*\n\n#### `set_field_weights(field_weights)`\n\nSet or update the field weights for the query.\n\n* **Parameters:**\n  **field_weights** (*str* *|* *Dict* *[* *str* *,* *float* *]*) – Either a single field name or dictionary of field:weight mappings\n\n#### `set_filter(filter_expression=None)`\n\nSet the filter expression for the query.\n\n* **Parameters:**\n  **filter_expression** (*Optional* *[* *Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *]* *,* *optional*) – The filter\n  expression or query string to use on the query.\n* **Raises:**\n  **TypeError** – If filter_expression is not a valid FilterExpression or string.\n\n#### `set_text_weights(weights)`\n\nSet or update the text weights for the query.\n\n* **Parameters:**\n  * **text_weights** – Dictionary of word:weight mappings\n  * **weights** (*Dict* *[* *str* *,* *float* *]*)\n\n#### `slop(slop)`\n\nAllow a maximum of N intervening non-matched terms between\nphrase terms (0 means exact phrase).\n\n* **Parameters:**\n  **slop** (*int*)\n* **Return type:**\n  *Query*\n\n#### `sort_by(sort_spec=None, asc=True)`\n\nSet the sort order for query results.\n\nThis method supports sorting by single or multiple fields. Note that Redis Search\nnatively supports only a single SORTBY field. When multiple fields are specified,\nonly the FIRST field is used for the Redis SORTBY clause.\n\n* **Parameters:**\n  * **sort_spec** (*str* *|* *Tuple* *[* *str* *,* *str* *]*  *|* *List* *[* *str* *|* *Tuple* *[* *str* *,* *str* *]* *]*  *|* *None*) – Sort specification in various formats:\n    - str: single field name\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\")\n    - List: list of field names or tuples\n  * **asc** (*bool*) – Default sort direction when not specified (only used when sort_spec is a string).\n    Defaults to True (ascending).\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  * **TypeError** – If sort_spec is not a valid type.\n  * **ValueError** – If direction is not \"ASC\" or \"DESC\".\n\n### `Examples`\n\n```pycon\n\u003e\u003e query.sort_by(\"price\")  # Single field, ascending\n\u003e\u003e query.sort_by((\"price\", \"DESC\"))  # Single field, descending\n\u003e\u003e query.sort_by([\"price\", \"rating\"])  # Multiple fields (only first used)\n\u003e\u003e query.sort_by([(\"price\", \"DESC\"), (\"rating\", \"ASC\")])\n```\n\n#### `NOTE`\nWhen multiple fields are specified, only the first field is used for sorting\nin Redis. Future versions may support multi-field sorting through post-query\nsorting in Python.\n\n#### `timeout(timeout)`\n\noverrides the timeout parameter of the module\n\n* **Parameters:**\n  **timeout** (*float*)\n* **Return type:**\n  *Query*\n\n#### `verbatim()`\n\nSet the query to be verbatim, i.e., use no query expansion\nor stemming.\n\n* **Return type:**\n  *Query*\n\n#### `with_payloads()`\n\nAsk the engine to return document payloads.\n\n* **Return type:**\n  *Query*\n\n#### `with_scores()`\n\nAsk the engine to return document search scores.\n\n* **Return type:**\n  *Query*\n\n#### `property field_weights: Dict[str, float]`\n\nGet the field weights for the query.\n\n* **Returns:**\n  Dictionary mapping field names to their weights\n\n#### `property filter: str | `[`FilterExpression`](https://redis.io/docs/latest/filter/#filterexpression)` `\n\nThe filter expression for the query.\n\n#### `property params: Dict[str, Any]`\n\nReturn the query parameters.\n\n#### `property query: BaseQuery`\n\nReturn self as the query object.\n\n#### `property text_field_name: str | Dict[str, float]`\n\nGet the text field name(s) - for backward compatibility.\n\n* **Returns:**\n  Either a single field name string (if only one field with weight 1.0)\n  or a dictionary of field:weight mappings.\n\n#### `property text_weights: Dict[str, float]`\n\nGet the text weights.\n\n* **Returns:**\n  weight mappings.\n* **Return type:**\n  Dictionary of word\n\n#### `NOTE`\nThe `stopwords` parameter in [TextQuery](#textquery) controls query-time stopword filtering (client-side).\nFor index-level stopwords configuration (server-side), see `redisvl.schema.IndexInfo.stopwords`.\nUsing query-time stopwords with index-level `STOPWORDS 0` is counterproductive.\n\n## FilterQuery\n\n### `class FilterQuery(filter_expression=None, return_fields=None, num_results=10, dialect=2, sort_by=None, in_order=False, params=None)`\n\nBases: `BaseQuery`\n\nA query for running a filtered search with a filter expression.\n\n* **Parameters:**\n  * **filter_expression** (*Optional* *[* *Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *]*) – The optional filter\n    expression to query with. Defaults to ‘\\*’.\n  * **return_fields** (*Optional* *[* *List* *[* *str* *]* *]* *,* *optional*) – The fields to return.\n  * **num_results** (*Optional* *[* *int* *]* *,* *optional*) – The number of results to return. Defaults to 10.\n  * **dialect** (*int* *,* *optional*) – The query dialect. Defaults to 2.\n  * **sort_by** (*Optional* *[* *SortSpec* *]* *,* *optional*) – The field(s) to order the results by. Can be:\n    - str: single field name (e.g., \"price\")\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\") (e.g., (\"price\", \"DESC\"))\n    - List: list of fields or tuples (e.g., [\"price\", (\"rating\", \"DESC\")])\n    Note: Redis Search only supports single-field sorting, so only the first field is used.\n    Defaults to None.\n  * **in_order** (*bool* *,* *optional*) – Requires the terms in the field to have the same order as the\n    terms in the query filter. Defaults to False.\n  * **params** (*Optional* *[* *Dict* *[* *str* *,* *Any* *]* *]* *,* *optional*) – The parameters for the query. Defaults to None.\n* **Raises:**\n  **TypeError** – If filter_expression is not of type redisvl.query.FilterExpression\n\n#### `dialect(dialect)`\n\nAdd a dialect field to the query.\n\n- **dialect** - dialect version to execute the query under\n\n* **Parameters:**\n  **dialect** (*int*)\n* **Return type:**\n  *Query*\n\n#### `expander(expander)`\n\nAdd an expander field to the query.\n\n- **expander** - the name of the expander\n\n* **Parameters:**\n  **expander** (*str*)\n* **Return type:**\n  *Query*\n\n#### `in_order()`\n\nMatch only documents where the query terms appear in\nthe same order in the document.\ni.e., for the query \"hello world\", we do not match \"world hello\"\n\n* **Return type:**\n  *Query*\n\n#### `language(language)`\n\nAnalyze the query as being in the specified language.\n\n* **Parameters:**\n  **language** (*str*) – The language (e.g. chinese or english)\n* **Return type:**\n  *Query*\n\n#### `limit_fields(*fields)`\n\nLimit the search to specific TEXT fields only.\n\n- **fields**: Each element should be a string, case sensitive field name\n\nfrom the defined schema.\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *Query*\n\n#### `limit_ids(*ids)`\n\nLimit the results to a specific set of pre-known document\nids of any length.\n\n* **Return type:**\n  *Query*\n\n#### `no_content()`\n\nSet the query to only return ids and not the document content.\n\n* **Return type:**\n  *Query*\n\n#### `no_stopwords()`\n\nPrevent the query from being filtered for stopwords.\nOnly useful in very big queries that you are certain contain\nno stopwords.\n\n* **Return type:**\n  *Query*\n\n#### `paging(offset, num)`\n\nSet the paging for the query (defaults to 0..10).\n\n- **offset**: Paging offset for the results. Defaults to 0\n- **num**: How many results do we want\n\n* **Parameters:**\n  * **offset** (*int*)\n  * **num** (*int*)\n* **Return type:**\n  *Query*\n\n#### `query_string()`\n\nReturn the query string of this query only.\n\n* **Return type:**\n  str\n\n#### `return_fields(*fields, skip_decode=None)`\n\nSet the fields to return with search results.\n\n* **Parameters:**\n  * **\\*fields** – Variable number of field names to return.\n  * **skip_decode** (*List* *[* *str* *]*  *|* *str* *|* *None*) – Optional field name or list of field names that should not be\n    decoded. Useful for binary data like embeddings.\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  **TypeError** – If skip_decode is not a string, list, or None.\n\n#### `scorer(scorer)`\n\nUse a different scoring function to evaluate document relevance.\nDefault is TFIDF.\n\nSince Redis 8.0 default was changed to BM25STD.\n\n* **Parameters:**\n  **scorer** (*str*) – The scoring function to use\n  (e.g. TFIDF.DOCNORM or BM25)\n* **Return type:**\n  *Query*\n\n#### `set_filter(filter_expression=None)`\n\nSet the filter expression for the query.\n\n* **Parameters:**\n  **filter_expression** (*Optional* *[* *Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *]* *,* *optional*) – The filter\n  expression or query string to use on the query.\n* **Raises:**\n  **TypeError** – If filter_expression is not a valid FilterExpression or string.\n\n#### `slop(slop)`\n\nAllow a maximum of N intervening non-matched terms between\nphrase terms (0 means exact phrase).\n\n* **Parameters:**\n  **slop** (*int*)\n* **Return type:**\n  *Query*\n\n#### `sort_by(sort_spec=None, asc=True)`\n\nSet the sort order for query results.\n\nThis method supports sorting by single or multiple fields. Note that Redis Search\nnatively supports only a single SORTBY field. When multiple fields are specified,\nonly the FIRST field is used for the Redis SORTBY clause.\n\n* **Parameters:**\n  * **sort_spec** (*str* *|* *Tuple* *[* *str* *,* *str* *]*  *|* *List* *[* *str* *|* *Tuple* *[* *str* *,* *str* *]* *]*  *|* *None*) – Sort specification in various formats:\n    - str: single field name\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\")\n    - List: list of field names or tuples\n  * **asc** (*bool*) – Default sort direction when not specified (only used when sort_spec is a string).\n    Defaults to True (ascending).\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  * **TypeError** – If sort_spec is not a valid type.\n  * **ValueError** – If direction is not \"ASC\" or \"DESC\".\n\n### `Examples`\n\n```pycon\n\u003e\u003e query.sort_by(\"price\")  # Single field, ascending\n\u003e\u003e query.sort_by((\"price\", \"DESC\"))  # Single field, descending\n\u003e\u003e query.sort_by([\"price\", \"rating\"])  # Multiple fields (only first used)\n\u003e\u003e query.sort_by([(\"price\", \"DESC\"), (\"rating\", \"ASC\")])\n```\n\n#### `NOTE`\nWhen multiple fields are specified, only the first field is used for sorting\nin Redis. Future versions may support multi-field sorting through post-query\nsorting in Python.\n\n#### `timeout(timeout)`\n\noverrides the timeout parameter of the module\n\n* **Parameters:**\n  **timeout** (*float*)\n* **Return type:**\n  *Query*\n\n#### `verbatim()`\n\nSet the query to be verbatim, i.e., use no query expansion\nor stemming.\n\n* **Return type:**\n  *Query*\n\n#### `with_payloads()`\n\nAsk the engine to return document payloads.\n\n* **Return type:**\n  *Query*\n\n#### `with_scores()`\n\nAsk the engine to return document search scores.\n\n* **Return type:**\n  *Query*\n\n#### `property filter: str | `[`FilterExpression`](https://redis.io/docs/latest/filter/#filterexpression)` `\n\nThe filter expression for the query.\n\n#### `property params: Dict[str, Any]`\n\nReturn the query parameters.\n\n#### `property query: BaseQuery`\n\nReturn self as the query object.\n\n## CountQuery\n\n### `class CountQuery(filter_expression=None, dialect=2, params=None)`\n\nBases: `BaseQuery`\n\nA query for a simple count operation provided some filter expression.\n\n* **Parameters:**\n  * **filter_expression** (*Optional* *[* *Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *]*) – The filter expression to\n    query with. Defaults to None.\n  * **params** (*Optional* *[* *Dict* *[* *str* *,* *Any* *]* *]* *,* *optional*) – The parameters for the query. Defaults to None.\n  * **dialect** (*int*)\n* **Raises:**\n  **TypeError** – If filter_expression is not of type redisvl.query.FilterExpression\n\n```python\nfrom redisvl.query import CountQuery\nfrom redisvl.query.filter import Tag\n\nt = Tag(\"brand\") == \"Nike\"\nquery = CountQuery(filter_expression=t)\n\ncount = index.query(query)\n```\n\n#### `dialect(dialect)`\n\nAdd a dialect field to the query.\n\n- **dialect** - dialect version to execute the query under\n\n* **Parameters:**\n  **dialect** (*int*)\n* **Return type:**\n  *Query*\n\n#### `expander(expander)`\n\nAdd an expander field to the query.\n\n- **expander** - the name of the expander\n\n* **Parameters:**\n  **expander** (*str*)\n* **Return type:**\n  *Query*\n\n#### `in_order()`\n\nMatch only documents where the query terms appear in\nthe same order in the document.\ni.e., for the query \"hello world\", we do not match \"world hello\"\n\n* **Return type:**\n  *Query*\n\n#### `language(language)`\n\nAnalyze the query as being in the specified language.\n\n* **Parameters:**\n  **language** (*str*) – The language (e.g. chinese or english)\n* **Return type:**\n  *Query*\n\n#### `limit_fields(*fields)`\n\nLimit the search to specific TEXT fields only.\n\n- **fields**: Each element should be a string, case sensitive field name\n\nfrom the defined schema.\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *Query*\n\n#### `limit_ids(*ids)`\n\nLimit the results to a specific set of pre-known document\nids of any length.\n\n* **Return type:**\n  *Query*\n\n#### `no_content()`\n\nSet the query to only return ids and not the document content.\n\n* **Return type:**\n  *Query*\n\n#### `no_stopwords()`\n\nPrevent the query from being filtered for stopwords.\nOnly useful in very big queries that you are certain contain\nno stopwords.\n\n* **Return type:**\n  *Query*\n\n#### `paging(offset, num)`\n\nSet the paging for the query (defaults to 0..10).\n\n- **offset**: Paging offset for the results. Defaults to 0\n- **num**: How many results do we want\n\n* **Parameters:**\n  * **offset** (*int*)\n  * **num** (*int*)\n* **Return type:**\n  *Query*\n\n#### `query_string()`\n\nReturn the query string of this query only.\n\n* **Return type:**\n  str\n\n#### `return_fields(*fields, skip_decode=None)`\n\nSet the fields to return with search results.\n\n* **Parameters:**\n  * **\\*fields** – Variable number of field names to return.\n  * **skip_decode** (*List* *[* *str* *]*  *|* *str* *|* *None*) – Optional field name or list of field names that should not be\n    decoded. Useful for binary data like embeddings.\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  **TypeError** – If skip_decode is not a string, list, or None.\n\n#### `scorer(scorer)`\n\nUse a different scoring function to evaluate document relevance.\nDefault is TFIDF.\n\nSince Redis 8.0 default was changed to BM25STD.\n\n* **Parameters:**\n  **scorer** (*str*) – The scoring function to use\n  (e.g. TFIDF.DOCNORM or BM25)\n* **Return type:**\n  *Query*\n\n#### `set_filter(filter_expression=None)`\n\nSet the filter expression for the query.\n\n* **Parameters:**\n  **filter_expression** (*Optional* *[* *Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *]* *,* *optional*) – The filter\n  expression or query string to use on the query.\n* **Raises:**\n  **TypeError** – If filter_expression is not a valid FilterExpression or string.\n\n#### `slop(slop)`\n\nAllow a maximum of N intervening non-matched terms between\nphrase terms (0 means exact phrase).\n\n* **Parameters:**\n  **slop** (*int*)\n* **Return type:**\n  *Query*\n\n#### `sort_by(sort_spec=None, asc=True)`\n\nSet the sort order for query results.\n\nThis method supports sorting by single or multiple fields. Note that Redis Search\nnatively supports only a single SORTBY field. When multiple fields are specified,\nonly the FIRST field is used for the Redis SORTBY clause.\n\n* **Parameters:**\n  * **sort_spec** (*str* *|* *Tuple* *[* *str* *,* *str* *]*  *|* *List* *[* *str* *|* *Tuple* *[* *str* *,* *str* *]* *]*  *|* *None*) – Sort specification in various formats:\n    - str: single field name\n    - Tuple[str, str]: (field_name, \"ASC\"|\"DESC\")\n    - List: list of field names or tuples\n  * **asc** (*bool*) – Default sort direction when not specified (only used when sort_spec is a string).\n    Defaults to True (ascending).\n* **Returns:**\n  Returns the query object for method chaining.\n* **Return type:**\n  self\n* **Raises:**\n  * **TypeError** – If sort_spec is not a valid type.\n  * **ValueError** – If direction is not \"ASC\" or \"DESC\".\n\n### `Examples`\n\n```pycon\n\u003e\u003e query.sort_by(\"price\")  # Single field, ascending\n\u003e\u003e query.sort_by((\"price\", \"DESC\"))  # Single field, descending\n\u003e\u003e query.sort_by([\"price\", \"rating\"])  # Multiple fields (only first used)\n\u003e\u003e query.sort_by([(\"price\", \"DESC\"), (\"rating\", \"ASC\")])\n```\n\n#### `NOTE`\nWhen multiple fields are specified, only the first field is used for sorting\nin Redis. Future versions may support multi-field sorting through post-query\nsorting in Python.\n\n#### `timeout(timeout)`\n\noverrides the timeout parameter of the module\n\n* **Parameters:**\n  **timeout** (*float*)\n* **Return type:**\n  *Query*\n\n#### `verbatim()`\n\nSet the query to be verbatim, i.e., use no query expansion\nor stemming.\n\n* **Return type:**\n  *Query*\n\n#### `with_payloads()`\n\nAsk the engine to return document payloads.\n\n* **Return type:**\n  *Query*\n\n#### `with_scores()`\n\nAsk the engine to return document search scores.\n\n* **Return type:**\n  *Query*\n\n#### `property filter: str | `[`FilterExpression`](https://redis.io/docs/latest/filter/#filterexpression)` `\n\nThe filter expression for the query.\n\n#### `property params: Dict[str, Any]`\n\nReturn the query parameters.\n\n#### `property query: BaseQuery`\n\nReturn self as the query object.\n\n## MultiVectorQuery\n\n### `class MultiVectorQuery(vectors, return_fields=None, filter_expression=None, num_results=10, dialect=2)`\n\nBases: `AggregationQuery`\n\nMultiVectorQuery allows for search over multiple vector fields in a document simultaneously.\nThe final score will be a weighted combination of the individual vector similarity scores\nfollowing the formula:\n\nscore = (w_1 \\* score_1 + w_2 \\* score_2 + w_3 \\* score_3 + … )\n\nVectors may be of different size and datatype, but must be indexed using the ‘cosine’ distance_metric.\n\n```python\nfrom redisvl.query import MultiVectorQuery, Vector\nfrom redisvl.index import SearchIndex\n\nindex = SearchIndex.from_yaml(\"path/to/index.yaml\")\n\nvector_1 = Vector(\n    vector=[0.1, 0.2, 0.3],\n    field_name=\"text_vector\",\n    dtype=\"float32\",\n    weight=0.7,\n)\nvector_2 = Vector(\n    vector=[0.5, 0.5],\n    field_name=\"image_vector\",\n    dtype=\"bfloat16\",\n    weight=0.2,\n)\nvector_3 = Vector(\n    vector=[0.1, 0.2, 0.3],\n    field_name=\"text_vector\",\n    dtype=\"float64\",\n    weight=0.5,\n)\n\nquery = MultiVectorQuery(\n    vectors=[vector_1, vector_2, vector_3],\n    filter_expression=None,\n    num_results=10,\n    return_fields=[\"field1\", \"field2\"],\n    dialect=2,\n)\n\nresults = index.query(query)\n```\n\nInstantiates a MultiVectorQuery object.\n\n* **Parameters:**\n  * **vectors** (*Union* *[*[*Vector*](https://redis.io/docs/latest/vector/#vector) *,* *List* *[*[*Vector*](https://redis.io/docs/latest/vector/#vector) *]* *]*) – The Vectors to perform vector similarity search.\n  * **return_fields** (*Optional* *[* *List* *[* *str* *]* *]* *,* *optional*) – The fields to return. Defaults to None.\n  * **filter_expression** (*Optional* *[* *Union* *[* *str* *,* [*FilterExpression*](https://redis.io/docs/latest/filter/#filterexpression) *]* *]*) – The filter expression to use.\n    Defaults to None.\n  * **num_results** (*int* *,* *optional*) – The number of results to return. Defaults to 10.\n  * **dialect** (*int* *,* *optional*) – The Redis dialect version. Defaults to 2.\n\n#### `add_scores()`\n\nIf set, includes the score as an ordinary field of the row.\n\n* **Return type:**\n  *AggregateRequest*\n\n#### `apply(**kwexpr)`\n\nSpecify one or more projection expressions to add to each result\n\n### `Parameters`\n\n- **kwexpr**: One or more key-value pairs for a projection. The key is\n  : the alias for the projection, and the value is the projection\n    expression itself, for example apply(square_root=\"sqrt(@foo)\")\n\n* **Return type:**\n  *AggregateRequest*\n\n#### `dialect(dialect)`\n\nAdd a dialect field to the aggregate command.\n\n- **dialect** - dialect version to execute the query under\n\n* **Parameters:**\n  **dialect** (*int*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `filter(expressions)`\n\nSpecify filter for post-query results using predicates relating to\nvalues in the result set.\n\n### `Parameters`\n\n- **fields**: Fields to group by. This can either be a single string,\n  : or a list of strings.\n\n* **Parameters:**\n  **expressions** (*str* *|* *List* *[* *str* *]*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `group_by(fields, *reducers)`\n\nSpecify by which fields to group the aggregation.\n\n### `Parameters`\n\n- **fields**: Fields to group by. This can either be a single string,\n  : or a list of strings. both cases, the field should be specified as\n    @field.\n- **reducers**: One or more reducers. Reducers may be found in the\n  : aggregation module.\n\n* **Parameters:**\n  * **fields** (*str* *|* *List* *[* *str* *]*)\n  * **reducers** (*Reducer*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `limit(offset, num)`\n\nSets the limit for the most recent group or query.\n\nIf no group has been defined yet (via group_by()) then this sets\nthe limit for the initial pool of results from the query. Otherwise,\nthis limits the number of items operated on from the previous group.\n\nSetting a limit on the initial search results may be useful when\nattempting to execute an aggregation on a sample of a large data set.\n\n### `Parameters`\n\n- **offset**: Result offset from which to begin paging\n- **num**: Number of results to return\n\nExample of sorting the initial results:\n\n``\nAggregateRequest(\"@sale_amount:[10000, inf]\")            .limit(0, 10)            .group_by(\"@state\", r.count())\n``\n\nWill only group by the states found in the first 10 results of the\nquery @sale_amount:[10000, inf]. On the other hand,\n\n``\nAggregateRequest(\"@sale_amount:[10000, inf]\")            .limit(0, 1000)            .group_by(\"@state\", r.count()            .limit(0, 10)\n``\n\nWill group all the results matching the query, but only return the\nfirst 10 groups.\n\nIf you only wish to return a *top-N* style query, consider using\nsort_by() instead.\n\n* **Parameters:**\n  * **offset** (*int*)\n  * **num** (*int*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `load(*fields)`\n\nIndicate the fields to be returned in the response. These fields are\nreturned in addition to any others implicitly specified.\n\n### `Parameters`\n\n- **fields**: If fields not specified, all the fields will be loaded.\n\nOtherwise, fields should be given in the format of @field.\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `scorer(scorer)`\n\nUse a different scoring function to evaluate document relevance.\nDefault is TFIDF.\n\n* **Parameters:**\n  **scorer** (*str*) – The scoring function to use\n  (e.g. TFIDF.DOCNORM or BM25)\n* **Return type:**\n  *AggregateRequest*\n\n#### `sort_by(*fields, **kwargs)`\n\nIndicate how the results should be sorted. This can also be used for\n*top-N* style queries\n\n### `Parameters`\n\n- **fields**: The fields by which to sort. This can be either a single\n  : field or a list of fields. If you wish to specify order, you can\n    use the Asc or Desc wrapper classes.\n- **max**: Maximum number of results to return. This can be\n  : used instead of LIMIT and is also faster.\n\nExample of sorting by foo ascending and bar descending:\n\n``\nsort_by(Asc(\"@foo\"), Desc(\"@bar\"))\n``\n\nReturn the top 10 customers:\n\n``\nAggregateRequest()            .group_by(\"@customer\", r.sum(\"@paid\").alias(FIELDNAME))            .sort_by(Desc(\"@paid\"), max=10)\n``\n\n* **Parameters:**\n  **fields** (*str*)\n* **Return type:**\n  *AggregateRequest*\n\n#### `with_schema()`\n\nIf set, the schema property will contain a list of [field, type]\nentries in the result object.\n\n* **Return type:**\n  *AggregateRequest*\n\n#### `property params: Dict[str, Any]`\n\nReturn the parameters for the aggregation.\n\n* **Returns:**\n  The parameters for the aggregation.\n* **Return type:**\n  Dict[str, Any]\n\n## SQLQuery\n\n### `class SQLQuery(sql, params=None)`\n\nBases: `object`\n\nA query class that translates SQL-like syntax into Redis queries.\n\nThis class allows users to write SQL SELECT statements that are\nautomatically translated into Redis FT.SEARCH or FT.AGGREGATE commands.\n\n```python\nfrom redisvl.query import SQLQuery\nfrom redisvl.index import SearchIndex\n\nindex = SearchIndex.from_existing(\"products\", redis_url=\"redis://localhost:6379\")\n\nsql_query = SQLQuery('''\n    SELECT title, price, category\n    FROM products\n    WHERE category = 'electronics' AND price \u003c 100\n''')\n\nresults = index.query(sql_query)\n```\n\n#### `NOTE`\nRequires the optional sql-redis package. Install with:\n`pip install redisvl[sql]`\n\nInitialize a SQLQuery.\n\n* **Parameters:**\n  * **sql** (*str*) – The SQL SELECT statement to execute.\n  * **params** (*Dict* *[* *str* *,* *Any* *]*  *|* *None*) – Optional dictionary of parameters for parameterized queries.\n    Useful for passing vector data for similarity searches.\n\n#### `redis_query_string(redis_client=None, redis_url='redis://localhost:6379')`\n\nTranslate the SQL query to a Redis command string.\n\nThis method uses the sql-redis translator to convert the SQL statement\ninto the equivalent Redis FT.SEARCH or FT.AGGREGATE command.\n\n* **Parameters:**\n  * **redis_client** (*Any* *|* *None*) – A Redis client connection used to load index schemas.\n    If not provided, a connection will be created using redis_url.\n  * **redis_url** (*str*) – The Redis URL to connect to if redis_client is not provided.\n    Defaults to \"redis://localhost:6379\".\n* **Returns:**\n  {electronics}\"’).\n* **Return type:**\n  The Redis command string (e.g., ‘FT.SEARCH products \"@category\n* **Raises:**\n  **ImportError** – If sql-redis package is not installed.\n\n### `Example`\n\n```python\nfrom redisvl.query import SQLQuery\n\nsql_query = SQLQuery(\"SELECT * FROM products WHERE category = 'electronics'\")\n\n# Using redis_url\nredis_cmd = sql_query.redis_query_string(redis_url=\"redis://localhost:6379\")\n\n# Or using an existing client\nfrom redis import Redis\nclient = Redis()\nredis_cmd = sql_query.redis_query_string(redis_client=client)\n\nprint(redis_cmd)\n# Output: FT.SEARCH products \"@category:{electronics}\"\n```\n\n#### `NOTE`\nSQLQuery requires the optional `sql-redis` package. Install with:\n`pip install redisvl[sql-redis]`\n\n#### `NOTE`\nSQLQuery translates SQL SELECT statements into Redis FT.SEARCH or FT.AGGREGATE commands.\nThe SQL syntax supports WHERE clauses, field selection, ordering, and parameterized queries\nfor vector similarity searches.\n",
  "tags": [],
  "last_updated": "2026-04-21T14:39:33+02:00"
}
