[[rest-api-add-a-relationship-to-an-index-unless-a-relationship-already-exists-for-the-given-mapping]]
=== Add a relationship to an index unless a relationship already exists for the given mapping ===

.Final Graph
["dot", "Final-Graph-Add-a-relationship-to-an-index-unless-a-relationship-already-exists-for-the-given-mapping.svg", "neoviz"]
----
  N70 [
    label = "{Node\[70\]|}"
  ]
  N70 -> N71 [
    color = "#2e3436"
    fontcolor = "#2e3436"
    label = "knowledge\n"
  ]
  N71 [
    label = "{Node\[71\]|}"
  ]
----

_Example request_

* *+POST+*  +http://localhost:7474/db/data/index/relationship/knowledge/?unique+
* *+Accept:+* +application/json+
* *+Content-Type:+* +application/json+
[source,javascript]
----
{"key": "name", "value":"Mattias", "uri": "http://localhost:7474/db/data/relationship/24"}
----


_Example response_

* *+201:+* +Created+
* *+Content-Type:+* +application/json+
* *+Location:+* +http://localhost:7474/db/data/index/relationship/knowledge/name/Mattias/24+
[source,javascript]
----
{
  "indexed" : "http://localhost:7474/db/data/index/relationship/knowledge/name/Mattias/24",
  "start" : "http://localhost:7474/db/data/node/70",
  "data" : {
  },
  "self" : "http://localhost:7474/db/data/relationship/24",
  "property" : "http://localhost:7474/db/data/relationship/24/properties/{key}",
  "properties" : "http://localhost:7474/db/data/relationship/24/properties",
  "type" : "knowledge",
  "extensions" : {
  },
  "end" : "http://localhost:7474/db/data/node/71"
}
----


