From ba0b011ce434be68f145ea486591be43bd63dcef Mon Sep 17 00:00:00 2001 From: Christopher Talib Date: Tue, 2 Jun 2020 15:44:24 +0200 Subject: [PATCH] save --- matcher/main.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/matcher/main.go b/matcher/main.go index 0540a33..cfd464b 100644 --- a/matcher/main.go +++ b/matcher/main.go @@ -134,7 +134,11 @@ func (m *Matcher) Run(wg *sync.WaitGroup, graphClient *dgo.Dgraph) { q := `query allofterms($a: string) { Node(func: allofterms(full, $a)) { uid - }}` + type + full + } + + }` ctx := context.Background() txn := graphClient.NewTxn() @@ -157,6 +161,7 @@ func (m *Matcher) Run(wg *sync.WaitGroup, graphClient *dgo.Dgraph) { Type: "matcher", } if len(n.Result) != 0 { + fmt.Println("first query res", res) // TODO: review time and id to be updated on new resulsts for _, res := range n.Result { @@ -173,19 +178,10 @@ func (m *Matcher) Run(wg *sync.WaitGroup, graphClient *dgo.Dgraph) { } } - // query := fmt.Sprintf(` - // query { - // (func: eq(id, "%s")) { - // uid - // } - // } - // `, matcher.ID) + query := `query { match as var(func: eq(target, "code")) } ` - query := `query { match as var(func: eq(target, "java")) } ` - - // nquads := fmt.Sprintf(`uid(match) "%v" .`, matcher.Nodes) fmt.Println("nodes", matcher.Nodes) - pb, err := json.Marshal(models.Match{UID: "uid(match)", Target: "java", Nodes: matcher.Nodes}) + pb, err := json.Marshal(models.Match{UID: "uid(match)", Target: "code", Nodes: matcher.Nodes, Type: "matcher"}) if err != nil { logrus.Fatal(err) } @@ -200,8 +196,8 @@ func (m *Matcher) Run(wg *sync.WaitGroup, graphClient *dgo.Dgraph) { CommitNow: true, } - fmt.Println("requests", req) - _, err = graphClient.NewTxn().Do(ctx, req) + ret, err := graphClient.NewTxn().Do(ctx, req) + fmt.Println(ret) if err != nil { logrus.Fatal(err) }