Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api/query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,9 @@ SQLQuery
narrow queries cheaper.
- ``"load_all"`` eagerly loads all schemas up front, which can help when
running many SQL queries across many indexes.

.. note::
SQLQuery supports hybrid search via ``hybrid_vector_search(cosine_distance(...), fulltext(...), rrf())``, which translates to a native Redis ``FT.HYBRID`` command
fusing a text and a vector query server-side. This is the SQL front-end to
:class:`HybridQuery` and requires ``sql-redis >= 0.7.0``, Redis 8.4+, and
redis-py >= 7.1.0.
Comment thread
rbs333 marked this conversation as resolved.
Comment on lines +265 to +269
21 changes: 21 additions & 0 deletions docs/concepts/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,27 @@ query = SQLQuery("""
""", params={"vec": embedding_bytes})
```

**Hybrid search (FT.HYBRID)** fuses a text query and a vector query server-side
with `hybrid_vector_search()`, composing `cosine_distance()` (vector leg) and
`fulltext()` (text leg) with `rrf()` or `linear()` fusion. This is the SQL
front-end to the native `HybridQuery` (above):

```python
query = SQLQuery("""
SELECT title,
hybrid_vector_search(
cosine_distance(embedding, :vec),
fulltext(description, 'gaming laptop'),
rrf()
) AS hybrid_score
FROM products
ORDER BY hybrid_score DESC
LIMIT 5
""", params={"vec": embedding_bytes})
```

Requires Redis 8.4+ and `redis-py >= 7.1.0`.

Use when your team is more comfortable with SQL syntax, or when integrating with tools that generate SQL.

```{note}
Expand Down
Loading
Loading