Skip to content

Replace Field Values

Description

You can replace existing field values with new values, using a POST command to the _in endpoint.

There are two ways to do this:

  1. Use the replace-mode flag.
  2. Use the special #markReplace indicator.

Note

The replace-mode flag and the #markReplace indicator should not be used in the same command. If they are, replace-mode overrides #markReplace.

Both methods are described in the following sections.

Syntax 1

URL: <cm-well-host>/_in

REST verb: POST

Mandatory parameters: replace-mode


Template:

curl -X POST "<cm-well-host>/_in?format=<format>&replace-mode" <triples with new field values>

URL example: N/A

Curl example (REST API):

curl -X POST "<cm-well-host>/_in?format=ttl&replace-mode" -H "Content-Type: text/plain" --data-binary @curlInput.txt

File Contents

<http://data.com/1-12345678> 
    <http://ont.com/bermuda/hasName> "John Smith" .

Parameters 1

Parameter

Description

Values

Example

Reference

format The format in which the triples are provided n3, rdfxml, ntriples, nquads, turtle/ttl, trig, trix format=n3/td> CM-Well Input and Output Formats
replace-mode Indicates that the new field value should replace the existing value, rather than be written as an additional value. See parameter value options below.
No value. replace-mode Replaces the field values that have the same quad value as the fields you're uploading. N/A
Default. replace-mode=default Replaces field values in the default graph (fields that have no quad value). N/A
Specific graph label. replace-mode=http://some-graph/uri Replaces field values that have the specified quad (graph label) value. N/A
All replace-mode=* Replaces all field values regardless of their quad value. N/A

Code Example 1

Call

curl -X POST "<cm-well-host>/_in?format=ttl&replace-mode" -H "Content-Type: text/plain" --data-binary @curlInput.txt

File Contents

<http://data.com/1-12345678> 
    <http://ont.com/bermuda/hasName> "John Smith" .

Results

{"success":true}

Syntax 2

URL: <CMWellHost>/_in

REST verb: POST

Mandatory parameters: None


Template:

curl -X POST <cm-well-host>/_in?format=<format> <triples with new field values>

URL example: N/A

Curl example (REST API):

curl -X POST "<cm-well-host>/_in?format=ttl " -H "Content-Type: text/plain" --data-binary @curlInput.txt

File Contents

<http://data.com/1-12345678> 
    <cmwell://meta/sys#markReplace> <http://ont.com/bermuda/hasName> . 
    <http://data.com/1-12345678> <http://ont.com/bermuda/hasName> "John Doe" . 

Note

For each field we want to replace, we supply two triples: one that indicates that the previous value should be deleted (using the #markReplace indicator), and one that provides the new value. You can supply several such pairs of triples, to replace several fields in the same call. You can also mix these pairs with other triples that just add values without deleting.

Parameters 2

Parameter Description Values Example Reference
format The format in which the triples are provided n3, rdfxml, ntriples, nquads, turtle/ttl, trig, trix format=n3 CM-Well Input and Output Formats

Code Example 2

Call

curl -X POST "<cm-well-host>/_in?format=ttl&replace-mode" -H "Content-Type: text/plain" --data-binary @curlInput.txt

File Contents

<http://data.com/1-12345678> 
    <http://ont.com/bermuda/hasName> "John Smith" .

Results

{"success":true}

Note

  • For best performance, if you're performing several replacements in one call, group the updates by subject, meaning that several triples referring to the same RDF subject should appear in sequence in the request payload.
  • If you add a value for a field that already has a value, the old value is not overwritten. Instead, the infoton will have two triples with the same field name but different values. To overwrite a field value, you must use the replace API calls described above.
  • If you want to replace field values, use the replace options rather than deleting values and adding new values in two separate calls. This is because each call that updates an infoton creates a new historical infoton version. The interim version with deleted fields just takes up storage needlessly.
  • If you attempt to perform an update on an infoton, where all of the "new" infotons triples are identical to the existing infoton's triples, no update will occur. This is in order to prevent saving a new infoton version when no actual change was made.

Add Infotons and Fields

Delete Fields

Replace a Named Sub-Graph