Qdrant: Search points (vectors)
qdrant_search_points.Rd
qdrant_search_points
searches for similar vectors (points)
'
Usage
qdrant_search_points(
conn,
collection_name = NA_character_,
vector = list(),
limit = 5,
with_payload = TRUE,
with_vector = FALSE,
score_threshold = NA_real_
)
Arguments
- conn
a connection object created by get_qdrant_connection()
- collection_name
the name of the collection you want to use. Defaults to NA.
- vector
a vector of embedding values that is used to initiate the search. Defaults to an empty list. Note that this vector is simply a list containing numerical values for your embeddings. If you use an embedding of size 384, this should be a simple list with 384 numerical values in it.
- limit
the maximum amount of vectors to return after the search. Defaults to 5.
- with_payload
if TRUE, will display the payload of the resulting vectors. Defaults to TRUE.
- with_vector
if TRUE, will display the full vector values in the results. Defaults to FALSE.
- score_threshold
a threshold for the minimum similarity score to return results. Defaults to NA.
Examples
conn <- get_qdrant_connection()
#> → Connection to Qdrant confirmed
qdrant_create_new_collection(conn, collection_name="test_db",
vectors=list(size=3,distance="Cosine"))
#> → Collection test_db was just created on the qdrant instance.
new_vectors <- list(points=list(
list(id=1, payload=list(text="hi there"),vector=list(0.1,0.5,0.6)),
list(id=2, payload=list(text="well well well"),vector=list(0.6,0.1,0.3))
))
qdrant_upsert_points(conn, points=new_vectors, collection_name="test_db")
#> → Vectors were added in the test_db collection on the qdrant instance.
qdrant_search_points(conn, collection_name="test_db", vector=list(0.2,0.5,0.6))
#> $result
#> $result[[1]]
#> $result[[1]]$id
#> [1] "9b96a1fe-1d54-4cbb-c960-cc6a0286668f"
#>
#> $result[[1]]$version
#> [1] 0
#>
#> $result[[1]]$score
#> [1] 0.9924029
#>
#> $result[[1]]$payload
#> $result[[1]]$payload$text
#> [1] "hi there"
#>
#>
#>
#> $result[[2]]
#> $result[[2]]$id
#> [1] "005ae072-9959-484d-19c5-b26b61200dd0"
#>
#> $result[[2]]$version
#> [1] 0
#>
#> $result[[2]]$score
#> [1] 0.6400773
#>
#> $result[[2]]$payload
#> $result[[2]]$payload$text
#> [1] "well well well"
#>
#>
#>
#>
#> $status
#> [1] "ok"
#>
#> $time
#> [1] 0.005961041
#>
qdrant_delete_collection(conn, "test_db")
#> → Collection test_db was just deleted on the qdrant instance.