feat(python): add search() method to async API (#2049)

Reviving #1966.

Closes #1938

The `search()` method can apply embeddings for the user. This simplifies
hybrid search, so instead of writing:

```python
vector_query = embeddings.compute_query_embeddings("flower moon")[0]
await (
    async_tbl.query()
    .nearest_to(vector_query)
    .nearest_to_text("flower moon")
    .to_pandas()
)
```

You can write:

```python
await (await async_tbl.search("flower moon", query_type="hybrid")).to_pandas()
```

Unfortunately, we had to do a double-await here because `search()` needs
to be async. This is because it often needs to do IO to retrieve and run
an embedding function.
This commit is contained in:
Will Jones
2025-02-24 14:19:25 -08:00
committed by GitHub
parent f391ed828a
commit ecdee4d2b1
10 changed files with 461 additions and 57 deletions

View File

@@ -338,6 +338,7 @@ def test_query_sync_empty_query():
"filter": "true",
"vector": [],
"columns": ["id"],
"prefilter": False,
"version": None,
}
@@ -412,6 +413,7 @@ def test_query_sync_fts():
"columns": [],
},
"k": 10,
"prefilter": True,
"vector": [],
"version": None,
}
@@ -429,6 +431,7 @@ def test_query_sync_fts():
},
"k": 42,
"vector": [],
"prefilter": True,
"with_row_id": True,
"version": None,
}
@@ -455,6 +458,7 @@ def test_query_sync_hybrid():
},
"k": 42,
"vector": [],
"prefilter": True,
"with_row_id": True,
"version": None,
}