# Bug: Adding Facets via JSON

**URL:** <https://discuss.dgraph.io/t/bug-adding-facets-via-json/11582>\
**Category:** Dgraph\
**Tags:** kind:question, json, dgraph, area:facets\
**Created:** [November 23, 2020, 2:19am UTC](https://discuss.dgraph.io/t/bug-adding-facets-via-json/11582 "2020-11-23T02:19:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamilabreu](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jamilabreu/32/5251_2.png) [@jamilabreu](https://discuss.dgraph.io/u/jamilabreu)\
**Post date:** [November 23, 2020, 2:19am UTC](https://discuss.dgraph.io/t/bug-adding-facets-via-json/11582/1 "2020-11-23T02:19:20Z")

</div>

I’m attempting to create facets via JSON using the method outlined here: [https://dgraph.io/docs/master/mutations/json-mutation-format/#facets-in-list-type-with-json](https://dgraph.io/docs/master/mutations/json-mutation-format/#facets-in-list-type-with-json)

but it’s only working when using RDF `_:Person <friends> _:Friend (order=0)`. Using the JSON version doesn’t create the facet:

```auto
{
  "set": [
    {
      "uid": "_:Person",
      "name": "Julian",
      "friends": [{"uid": "_:Friend", "name": "Bob"}],
      "friends|order": {
        "0": 0
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)\
**Post date:** [November 23, 2020, 3:31am UTC](https://discuss.dgraph.io/t/bug-adding-facets-via-json/11582/2 "2020-11-23T03:31:09Z")

</div>

Hi @jamilabreu  
The example you have cited is for list-type predicates (list of strings, ints etc.). You are trying to create uid predicates (or nodes). Please try the following mutation.

```auto
{
  "set": [
    {
      "uid": "_:Person",
      "name": "James",      
      "friends": {
        "uid": "_:Friend",
        "name": "Bob",
        "friends|order": 0
      }
    }
  ]
}

```

This can be queried as below.

```auto
{
  q(func: eq(name,"James")){
    name
    friends @facets(order){
      name
    }
  }
}

```

Result:

```auto
{
  "data": {
    "q": [
      {
        "name": "James",
        "friends": [
          {
            "name": "Bob",
            "friends|order": 0
          }
        ]
      }
    ]
  }
}

```

You will find related documentation [here](https://dgraph.io/docs/master/mutations/json-mutation-format/#facets).

---

<div class="post-metadata">

**Author:** ![jamilabreu](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jamilabreu/32/5251_2.png) [@jamilabreu](https://discuss.dgraph.io/u/jamilabreu)\
**Post date:** [November 23, 2020, 3:55am UTC](https://discuss.dgraph.io/t/bug-adding-facets-via-json/11582/3 "2020-11-23T03:55:10Z")

</div>

Got it! Thanks
