Skip to content

Commit 426794a

Browse files
committed
Give a name to the distance result column in the query
1 parent bcee6de commit 426794a

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,24 @@ Now you can query for similar items:
7474
await vec.search([1.0, 9.0])
7575
```
7676

77-
[<Record id=UUID('ae68bcbf-52e7-4977-b4b9-d2c954c3b8b4') metadata='{"action": "jump", "animal": "fox"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) ?column?=0.00016793422934946456>,
78-
<Record id=UUID('a76f2c30-f001-4e1a-abed-a2a0ce6aa8fe') metadata='{"animal": "fox"}' contents='the brown fox' embedding=array([1. , 1.3], dtype=float32) ?column?=0.14489260377438218>]
77+
[<Record id=UUID('393ef5c7-1587-468e-870c-b9a6a6716321') metadata='{"action": "jump", "animal": "fox"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) distance=0.00016793422934946456>,
78+
<Record id=UUID('7bec0df8-463f-4ea9-8d50-197906f9237e') metadata='{"animal": "fox"}' contents='the brown fox' embedding=array([1. , 1.3], dtype=float32) distance=0.14489260377438218>]
7979

8080
You can specify the number of records to return.
8181

8282
``` python
8383
await vec.search([1.0, 9.0], k=1)
8484
```
8585

86-
[<Record id=UUID('ae68bcbf-52e7-4977-b4b9-d2c954c3b8b4') metadata='{"action": "jump", "animal": "fox"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) ?column?=0.00016793422934946456>]
86+
[<Record id=UUID('393ef5c7-1587-468e-870c-b9a6a6716321') metadata='{"action": "jump", "animal": "fox"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) distance=0.00016793422934946456>]
8787

8888
You can also specify a filter on the metadata as a simple dictionary
8989

9090
``` python
9191
await vec.search([1.0, 9.0], k=1, filter={"action": "jump"})
9292
```
9393

94-
[<Record id=UUID('ae68bcbf-52e7-4977-b4b9-d2c954c3b8b4') metadata='{"action": "jump", "animal": "fox"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) ?column?=0.00016793422934946456>]
94+
[<Record id=UUID('393ef5c7-1587-468e-870c-b9a6a6716321') metadata='{"action": "jump", "animal": "fox"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) distance=0.00016793422934946456>]
9595

9696
## Advanced Usage
9797

nbs/00_vector.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
" params = params + [json_object]\n",
223223
" query = '''\n",
224224
" SELECT\n",
225-
" id, metadata, contents, embedding, {distance}\n",
225+
" id, metadata, contents, embedding, {distance} as distance\n",
226226
" FROM\n",
227227
" {table_name}\n",
228228
" WHERE \n",

nbs/index.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188
{
189189
"data": {
190190
"text/plain": [
191-
"[<Record id=UUID('ae68bcbf-52e7-4977-b4b9-d2c954c3b8b4') metadata='{\"action\": \"jump\", \"animal\": \"fox\"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) ?column?=0.00016793422934946456>,\n",
192-
" <Record id=UUID('a76f2c30-f001-4e1a-abed-a2a0ce6aa8fe') metadata='{\"animal\": \"fox\"}' contents='the brown fox' embedding=array([1. , 1.3], dtype=float32) ?column?=0.14489260377438218>]"
191+
"[<Record id=UUID('393ef5c7-1587-468e-870c-b9a6a6716321') metadata='{\"action\": \"jump\", \"animal\": \"fox\"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) distance=0.00016793422934946456>,\n",
192+
" <Record id=UUID('7bec0df8-463f-4ea9-8d50-197906f9237e') metadata='{\"animal\": \"fox\"}' contents='the brown fox' embedding=array([1. , 1.3], dtype=float32) distance=0.14489260377438218>]"
193193
]
194194
},
195195
"execution_count": null,
@@ -216,7 +216,7 @@
216216
{
217217
"data": {
218218
"text/plain": [
219-
"[<Record id=UUID('ae68bcbf-52e7-4977-b4b9-d2c954c3b8b4') metadata='{\"action\": \"jump\", \"animal\": \"fox\"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) ?column?=0.00016793422934946456>]"
219+
"[<Record id=UUID('393ef5c7-1587-468e-870c-b9a6a6716321') metadata='{\"action\": \"jump\", \"animal\": \"fox\"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) distance=0.00016793422934946456>]"
220220
]
221221
},
222222
"execution_count": null,
@@ -243,7 +243,7 @@
243243
{
244244
"data": {
245245
"text/plain": [
246-
"[<Record id=UUID('ae68bcbf-52e7-4977-b4b9-d2c954c3b8b4') metadata='{\"action\": \"jump\", \"animal\": \"fox\"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) ?column?=0.00016793422934946456>]"
246+
"[<Record id=UUID('393ef5c7-1587-468e-870c-b9a6a6716321') metadata='{\"action\": \"jump\", \"animal\": \"fox\"}' contents='jumped over the' embedding=array([ 1. , 10.8], dtype=float32) distance=0.00016793422934946456>]"
247247
]
248248
},
249249
"execution_count": null,

timescale_vector/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def search_query(self, query_embedding: List[float], k: int=10, filter: Optional
156156
params = params + [json_object]
157157
query = '''
158158
SELECT
159-
id, metadata, contents, embedding, {distance}
159+
id, metadata, contents, embedding, {distance} as distance
160160
FROM
161161
{table_name}
162162
WHERE

0 commit comments

Comments
 (0)