-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add vector support for graphQL #9067
Conversation
6474add
to
0dc9fcd
Compare
@@ -669,6 +673,13 @@ func genDgSchema(gqlSch *ast.Schema, definitions []string, | |||
} | |||
} | |||
|
|||
embedding := f.Directives.ForName(embeddingDirective) | |||
if embedding != nil { | |||
// embeddingValidation ensured GQL type is [Float] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we first have a schema with normal [Float], but then we add embedding
if field.Type.NamedType == "String" || | ||
field.Type.NamedType == "Int" || | ||
field.Type.NamedType == "Int64" { | ||
if field.Type.String() == "String!" || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test
// hnsw | ||
// hnsw(exponent: 3) | ||
func parseSearchOptions(searchArg string) (map[string]string, bool) { | ||
searchArg = strings.TrimSpace(searchArg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests
// } | ||
func rewriteAsSimilarByEmbeddingQuery( | ||
query schema.Query, auth *authRewriter) []*dql.GraphQuery { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you cehck if auth works?
59622a2
to
dd806c2
Compare
dd806c2
to
86f5035
Compare
query/vector_graphql_test.go
Outdated
type Project { | ||
id: ID! | ||
title: String! @search(by: [exact]) | ||
title_v: [Float!] @hm_embedding @search(by: ["hnsw(metric: euclidian, exponent: 4)"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just @ embedding
@@ -37,7 +37,7 @@ func TestDgraphMapping_WithoutDirectives(t *testing.T) { | |||
type Author { | |||
id: ID! | |||
|
|||
name: String! @search(by: [hash, trigram]) | |||
name: String! @search(by: ["hash", "trigram"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old thing should still work. We should not expect customers to change this
Product.title : Product.title | ||
Product.productVector : Product.productVector | ||
dgraph.uid : uid | ||
Product.hm_distance : val(distance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm_distance to distance
} | ||
|
||
type Project1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this to ProjectDotProduct, and ProjectCosine instead
Title format:
Topic(Area): Feature
Topic
must be one ofbuild|ci|docs|feat|fix|perf|refactor|chore|test
Area
must be one ofacl|audit|backup|badger|cdc|dql|export|graphql|indexing|multi-tenancy|raft|restore|upgrade|zero
Body Format:
Description:
Fixes:
Closes:
Docs: