Updating document quality

A little-used MarkLogic feature (from what I’ve seen) is the ability to change a document’s quality. Lowering this value will make it drop in search results, while increasing it will make it more prominent.

For one client, we’re allowing subject matter experts to lower the quality of documents that aren’t very helpful. They get a button that is hidden from regular users. Clicking the button sends a request to the middle tier, which in turn uses MarkLogic’s REST API to change the quality of the target document. This can be accomplished with a PUT request to /v1/documents.

There was only one thing that threw us off for a moment: we thought we could handle this through the URL parameters, but with no message body, we got a 400 error. Here’s what to do instead, presented as a curl command:

curl --location 
  --request PUT \
  'http://localhost:8010/v1/documents?uri=/content/1234.json&category=quality' \
  --header 'Content-Type: application/json' \
  --data-raw '{ "quality": 10 }'

I’m leaving authentication as an exercise for the reader, but this shows specifying the needed information in the body. Hope that helps someone!

Leave a Reply

Your email address will not be published. Required fields are marked *