Dgraph automatically generates GraphQL queries for each vector index that you define in your schema. There are two types of queries generated for each index.
@search
directive.
For example
querySimilar<Object>ByEmbedding
query
allows us to run similarity search using the vector index specified in our
schema.
vector_distance
. The vector_distance
is the Euclidean distance between the
name_v
embedding vector and the input vector used in our query.
Note: you can omit vector_distance
predicate in the query, the result is still
ordered by vector_distance
.
The distance metric used is specified in the index creation.
Similarly, the auto-generated querySimilar<Object>ById
query allows us to
search for similar objects to an existing object, given itβs Id. using the
function.
0xef7
.