Skip to content

Commit

Permalink
Added similar_to
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshil Goel committed Apr 1, 2024
1 parent 7650964 commit bea94a4
Show file tree
Hide file tree
Showing 30 changed files with 3,307 additions and 141 deletions.
4 changes: 4 additions & 0 deletions dgraph/cmd/zero/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/dgraph-io/badger/v4/y"
"github.com/dgraph-io/dgo/v230/protos/api"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/tok/hnsw"
"github.com/dgraph-io/dgraph/x"
"github.com/dgraph-io/ristretto/z"
)
Expand Down Expand Up @@ -376,6 +377,9 @@ func (s *Server) commit(ctx context.Context, src *api.TxnContext) error {
return errors.Wrapf(err, "unable to parse group id from %s", pkey)
}
pred := splits[1]
if strings.Contains(pred, hnsw.VecKeyword) {
pred = pred[0:strings.Index(pred, hnsw.VecKeyword)]
}
tablet := s.ServingTablet(pred)
if tablet == nil {
return errors.Errorf("Tablet for %s is nil", pred)
Expand Down
6 changes: 3 additions & 3 deletions dgraphtest/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func init() {
if err != nil {
panic(err)
}
if err := ensureDgraphClone(); err != nil {
panic(err)
}
//if err := ensureDgraphClone(); err != nil {
// panic(err)
//}

log.Printf("[INFO] baseRepoDir: %v", baseRepoDir)
log.Printf("[INFO] repoDir: %v", repoDir)
Expand Down
19 changes: 10 additions & 9 deletions dql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ import (
)

const (
uidFunc = "uid"
valueFunc = "val"
typFunc = "type"
lenFunc = "len"
countFunc = "count"
uidInFunc = "uid_in"
uidFunc = "uid"
valueFunc = "val"
typFunc = "type"
lenFunc = "len"
countFunc = "count"
uidInFunc = "uid_in"
similarToFn = "similar_to"
)

var (
Expand Down Expand Up @@ -356,7 +357,7 @@ func parseValue(v varInfo) (types.Val, error) {
}, nil
}
}
case "vfloat":
case "vector32float":
{
if i, err := types.ParseVFloat(v.Value); err != nil {
return types.Val{}, errors.Wrapf(err, "Expected a vfloat but got %v", v.Value)
Expand Down Expand Up @@ -1711,7 +1712,7 @@ func validFuncName(name string) bool {

switch name {
case "regexp", "anyofterms", "allofterms", "alloftext", "anyoftext",
"has", "uid", "uid_in", "anyof", "allof", "type", "match":
"has", "uid", "uid_in", "anyof", "allof", "type", "match", "similar_to":
return true
}
return false
Expand Down Expand Up @@ -1884,7 +1885,7 @@ L:
case IsInequalityFn(function.Name):
err = parseFuncArgs(it, function)

case function.Name == "uid_in":
case function.Name == "uid_in" || function.Name == "similar_to":
err = parseFuncArgs(it, function)

default:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ require (
go.opencensus.io v0.24.0
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.21.0
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
golang.org/x/net v0.22.0
golang.org/x/sync v0.6.0
golang.org/x/sys v0.18.0
Expand Down Expand Up @@ -141,7 +142,6 @@ require (
github.com/xdg/stringprep v1.0.3 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/api v0.122.0 // indirect
Expand Down
Loading

0 comments on commit bea94a4

Please sign in to comment.