Execute a hybrid search using both text and vector queries Args: - **query**: HybridQuery object Contains the text and vector queries - **combine_method**: CombineResultsMethod object Contains the combine metho
(
self,
query: HybridQuery,
combine_method: Optional[CombineResultsMethod] = None,
post_processing: Optional[HybridPostProcessingConfig] = None,
params_substitution: Optional[Dict[str, Union[str, int, float, bytes]]] = None,
timeout: Optional[int] = None,
cursor: Optional[HybridCursorQuery] = None,
)
| 1789 | |
| 1790 | @experimental_method() |
| 1791 | async def hybrid_search( |
| 1792 | self, |
| 1793 | query: HybridQuery, |
| 1794 | combine_method: Optional[CombineResultsMethod] = None, |
| 1795 | post_processing: Optional[HybridPostProcessingConfig] = None, |
| 1796 | params_substitution: Optional[Dict[str, Union[str, int, float, bytes]]] = None, |
| 1797 | timeout: Optional[int] = None, |
| 1798 | cursor: Optional[HybridCursorQuery] = None, |
| 1799 | ) -> Union[HybridResult, HybridCursorResult, Pipeline]: |
| 1800 | """ |
| 1801 | Execute a hybrid search using both text and vector queries |
| 1802 | |
| 1803 | Args: |
| 1804 | - **query**: HybridQuery object |
| 1805 | Contains the text and vector queries |
| 1806 | - **combine_method**: CombineResultsMethod object |
| 1807 | Contains the combine method and parameters |
| 1808 | - **post_processing**: HybridPostProcessingConfig object |
| 1809 | Contains the post processing configuration |
| 1810 | - **params_substitution**: Dict[str, Union[str, int, float, bytes]] |
| 1811 | Contains the parameters substitution |
| 1812 | - **timeout**: int - contains the timeout in milliseconds |
| 1813 | - **cursor**: HybridCursorQuery object - contains the cursor configuration |
| 1814 | |
| 1815 | |
| 1816 | For more information see `FT.SEARCH <https://redis.io/commands/ft.hybrid>`. |
| 1817 | """ |
| 1818 | index = self.index_name |
| 1819 | options = {} |
| 1820 | pieces = [HYBRID_CMD, index] |
| 1821 | pieces.extend(query.get_args()) |
| 1822 | if combine_method: |
| 1823 | pieces.extend(combine_method.get_args()) |
| 1824 | if post_processing: |
| 1825 | pieces.extend(post_processing.build_args()) |
| 1826 | options["post_processing"] = post_processing |
| 1827 | if params_substitution: |
| 1828 | pieces.extend(self.get_params_args(params_substitution)) |
| 1829 | if timeout: |
| 1830 | pieces.extend(("TIMEOUT", timeout)) |
| 1831 | if cursor: |
| 1832 | options["cursor"] = True |
| 1833 | pieces.extend(cursor.build_args()) |
| 1834 | |
| 1835 | # Preserve HYBRID result values as bytes by default, matching the |
| 1836 | # legacy RESP2 Search surface; selected LOAD fields can opt into |
| 1837 | # decoding through HybridPostProcessingConfig.load(..., decode_field=True). |
| 1838 | options[NEVER_DECODE] = True |
| 1839 | options["query"] = query |
| 1840 | |
| 1841 | res = await self.execute_command(*pieces, **options) |
| 1842 | |
| 1843 | if isinstance(res, Pipeline): |
| 1844 | return res |
| 1845 | |
| 1846 | return self._parse_results(HYBRID_CMD, res, **options) |
| 1847 | |
| 1848 | async def aggregate( |
nothing calls this directly
no test coverage detected