This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Updating Documents
isubiker edited this page Jan 11, 2012
·
19 revisions
Documents are updated using the /store
endpoint.
To update the content of a document or any of its metadata, send a POST request to the /store
endpoint, including the uri
parameter of the document to be updated. If there is no document in the database with that URI, an insert is performed.
Outside of the content of the document, it can also have properties, collections, permissions and a quality assigned to it. All of these dimensions can be updated independently or together. To update the content of the document, the body of the request should be set to either the XML, JSON, text or binary document itself.
- Endpoint: /store - For updating the content, permissions, properties, quality and content of XML, JSON, text or binary documents
- Request type: POST
- Request body should be the XML, JSON, text or binary document when updating the content of the document
- Parmeters:
- uri - The URI of the document to be modified
- permission (optional, multiple) - Must follow a
<role>:<capability>
pattern where capability is one of read, update or execute. If the permission does not exist, a 400 is returned. - property (optional, multiple) - Must follow a
<key>:<value>
pattern where the key is alphanumeric and starts with a letter - collection (optional, multiple) - A collection can be any string, can be thought of as tags
- quality (optional) - An number between -16 and 16
- txid (optional) - A pre-existing transaction ID in which the update should be performed. See creating transactions for more info. Note: If running in a clustered environment, document update requests must be issued to the same host that created the ticket.
- contentType (optional) - Without specifying a contentType, the extension in the URI is used to sniff the content type. The contentType parameter can be explicitly provided to override detected type. Valid values are:
xml
,json
,text
orbinary
. - moveTo (optional) - Moves the document at the specified URI (via
uri
parameter) to a new URI. - contentForBinary (optional) - When updating a binary document, this parameter can be used to augment that document with a searchable representation (in either XML or JSON formats).
- extractMetadata (binary, optional) - When updating a binary document metadata in the file will be attempted to be extracted. Setting this value to false turns this behavior off.
- extractContent (binary, optional) - When updating a binary document text content in the file will be attempted to be extracted. Setting this value to false turns this behavior off.
- applyTransform (optional) - Applies a transformer to the supplied content before updating. If updating a binary document, the transformer will be handed whatever text content could be extracted from the binary.
- respondWithContent (boolean, default: false) - If set to true, the response body will contain the content that was updated. Useful in conjunction with applyTransform.
- repair (boolean, default: false) - If set to true, MarkLogic will attempt to repair any malformed content that has been sent in the request body.
- Returns
- On success a 204 is returned with an empty body if respondWithContent is set to false (default). If respondWithContent is set to true a 200 will be returned along with the content that was updated.
- If updating a document that can't be parsed as the specified contentType, a 400 is returned
- If a permission is specified that doesn't exist, a 400 is returned.
- /store?uri=/foo/bar.json - Will update the JSON document in the database with the uri of "/foo/bar.json"
- /store?uri=/foo/bar.xml - Will update the XML document in the database with the uri of "/foo/bar.xml"
- /store?uri=/foo/bar.xml&permission=public:read&permission=admin:write
- /store?uri=/foo/bar.xml&property=key:value&property=published:false
- /store?uri=/foo/bar.xml&collection=public&collection=published
- /store?uri=/foo/bar.xml&quality=10
- /store?uri=/foo/bar.xml&permission=public:read&collection=public&quality=10