# Delete all syntax does not work in the java client

**URL:** <https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752>\
**Category:** Dgraph Clients\
**Tags:** kind:question, dgraph4j, accepted\
**Created:** [July 24, 2019, 8:47pm UTC](https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752 "2019-07-24T20:47:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 24, 2019, 8:47pm UTC](https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752/1 "2019-07-24T20:47:22Z")

</div>

_Posted by_ [hherman1](https://github.com/hherman1):

Currently the only way to issue deletes for triples like “uid \* \* .” is through the JSON syntax. If I try to use NQuads its first of all not clear whether I should be setting a target object id or string value, but either way it complains about using \* as a target object id or target value. Or perhaps using it as a predicate was the problem. The exception is unclear.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 29, 2019, 7:37pm UTC](https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752/2 "2019-07-29T19:37:21Z")

</div>

[gitlw](https://github.com/gitlw) _commented_ :

@hherman1 Thanks for creating this issue. Can you please let me know which version of Dgraph you are using?

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 29, 2019, 8:02pm UTC](https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752/3 "2019-07-29T20:02:36Z")

</div>

[hherman1](https://github.com/hherman1) _commented_ :

@gitlw Sure! 1.0.16

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 29, 2019, 8:56pm UTC](https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752/4 "2019-07-29T20:56:31Z")

</div>

[gitlw](https://github.com/gitlw) _commented_ :

@hherman1 It seems that the deletion in NQuads format works fine. Here is a simple example

1. creating a simple schema

```auto
curl localhost:8180/alter -XPOST -d '
name: string @index(exact) .
friend: uid @reverse .
'

```

1. Insert some data

```auto
curl 'localhost:8180/mutate' -H 'Content-Type:application/rdf' -H 'X-Dgraph-CommitNow: true' -XPOST -d '{
  set {
    _:alice <name> "Alice" .
    _:bob <name> "Bob" .
    _:alice <friend> _:bob .
  }
}'

```

1. Query the data and verify that they have been successfully inserted

```auto
curl localhost:8180/query -XPOST -d '{
 run(func: eq(name, "Alice")) {
    uid
   name
    friend {
        uid
        name
    }
 }
}' | python -m json.tool

```

This will give a result like

```auto
{
    "data": {
        "run": [
            {
                "friend": [
                    {
                        "name": "Bob",
                        "uid": "0x2"
                    }
                ],
                "name": "Alice",
                "uid": "0x1"
            }
        ]
    },
    "extensions": {
        "server_latency": {
            "encoding_ns": 494108,
            "parsing_ns": 16501,
            "processing_ns": 407245183
        },
        "txn": {
            "start_ts": 4
        }
    }
}

```

1. Now we can delete the node with uid 0x01 using deletion in NQuad format

```auto
 curl 'localhost:8180/mutate' -H 'X-Dgraph-CommitNow: true' -H 'Content-Type:application/rdf' -XPOST -d '{
  delete {
    <0x01> * * .
  }
}'

```

1. If we run the query above again, the node representing “Alice” will be gone.

Am I missing something? Thanks!

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 29, 2019, 10:08pm UTC](https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752/5 "2019-07-29T22:08:18Z")

</div>

[hherman1](https://github.com/hherman1) _commented_ :

Yes! I’m reporting this as a bug against the dgraph4j DSL not a bug with Dgraph itself. The problem is it appears you can’t specify the RDF deletion format from your step 4 in the DSL and actually execute it. Whether I tried specifying an objectId or a objectValue as \* in both cases I got errors when trying to execute the query.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [December 29, 2019, 11:30am UTC](https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752/6 "2019-12-29T11:30:32Z")

</div>

[mangalaman93](https://github.com/mangalaman93) _commented_ :

@hherman1 We provide an API function `Helpers.deleteEdges` to delete predicates for a given uid (node). You could use that or do what it internally does, copying it here -

```auto
public static DgraphProto.Mutation deleteEdges(
      DgraphProto.Mutation mu, String uid, String... predicates) {
    DgraphProto.Mutation.Builder b = DgraphProto.Mutation.newBuilder(mu);
    for (String predicate : predicates) {
      b.addDel(
          DgraphProto.NQuad.newBuilder()
              .setSubject(uid)
              .setPredicate(predicate)
              .setObjectValue(DgraphProto.Value.newBuilder().setDefaultVal("_STAR_ALL").build())
              .build());
    }
    return b.build();
  }

```

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 11, 2020, 1:42am UTC](https://discuss.dgraph.io/t/delete-all-syntax-does-not-work-in-the-java-client/7752/7 "2020-07-11T01:42:01Z")

</div>


