MarkLogic 9.2通过Management API设置元数据字段报错,求解决方案
Let's break down what's happening here and fix your issue:
Root Cause of the 500 Error
The error XDMP-UNDFUN: Undefined function Q{http://marklogic.com/xdmp/admin}database-set-field-metadata() occurs because MarkLogic 9.2 does not include the admin:database-set-field-metadata() function. This function was introduced in MarkLogic 10, so trying to trigger it via the Management API in 9.2 will fail outright.
Your request uses the metadata property, which is a MarkLogic 10+ feature. The schema you referenced likely belongs to newer versions (hence the requirement for an empty string), but this detail is irrelevant because the underlying administrative function doesn't exist in 9.2.
Correct Approach for MarkLogic 9.2
In MarkLogic 9, metadata fields are configured using the metadata-kind property instead of metadata. You need to specify exactly which type of system metadata the field should map to (e.g., document URIs, collections, permissions).
Here's the corrected PUT request to create a metadata field in 9.2:
PUT /manage/v2/databases/mydb/properties Accept: application/json Content-Type: application/json
Request body (replace "uri" with your desired metadata type):
{ "field": [ { "field-name": "foobar", "metadata-kind": "uri" } ] }
Valid values for metadata-kind in MarkLogic 9 include:
uri: Maps to document URIscollection: Maps to document collectionspermissions: Maps to document permissionsquality: Maps to document quality scoresproperties: Maps to document properties
Additional Notes
- If you're modifying an existing field to act as a metadata field, use the same
metadata-kindproperty—there's no need for a separatemetadataflag in 9.2. - Always cross-reference the Management API documentation specific to your MarkLogic 9.2 version; the
metadataproperty won't be listed there, as it's a later addition.
内容的提问来源于stack exchange,提问作者Florent Georges

