Reputation: 1221
Metadata categories in Marklogic are (what I found in documentation):
collections, permissions, properties, quality and metadata.
Is there a way so that I can create additional categories in metadata?
Example:
metadata of ML document:
<?xml version="1.0" encoding="UTF-8"?>
<rapi:metadata uri="/abc/123.xml" xsi:schemaLocation="http://marklogic.com/rest-api/database dbmeta.xsd"
xmlns:rapi="http://marklogic.com/rest-api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<rapi:collections>
<rapi:collection>numerics</rapi:collection>
</rapi:collections>
<rapi:permissions/>
<prop:properties
xmlns:prop="http://marklogic.com/xdmp/property">
<property1>1</property1>
<property2>2</property2>
</prop:properties>
<rapi:quality>0</rapi:quality>
</rapi:metadata>
is there a way to change my metadata in Marklogic so that it'll be like:
<?xml version="1.0" encoding="UTF-8"?>
<rapi:metadata uri="/abc/123.xml" xsi:schemaLocation="http://marklogic.com/rest-api/database dbmeta.xsd"
xmlns:rapi="http://marklogic.com/rest-api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<itemId>1</itemId>
<itemName>abc</itemName>
<rapi:collections>
<rapi:collection>numerics</rapi:collection>
</rapi:collections>
<rapi:permissions/>
<prop:properties
xmlns:prop="http://marklogic.com/xdmp/property">
<property1>1</property1>
<property2>2</property2>
</prop:properties>
<rapi:quality>0</rapi:quality>
</rapi:metadata>
to add additional fields in marklogic metadata?
Upvotes: 2
Views: 91
Reputation: 7335
A footnote on Geert's good advice above: for JSON or XML content, the best practice is put the metadata and the content in the document itself. That approach gives you the most flexibility for search and performs best.
One way to model your documents for storing both metadata and content is to follow the same basic approach as HTML:
In HTML, the envelope is "html", the metadata bin is "head", and the content bin is "body." You can follow HTML or use whatever name is appropriate.
That said, for binary or text documents, you can only put metadata in the properties, and if you need to maintain metadata consistently across document formats that include either binary or text as well as JSON or XML, then the best practice is to use properties.
Upvotes: 1
Reputation: 20414
No, you can't add new categories that way. It would require changing MLCP as well.
But the contents of <prop:properties>
is free format, you can add as many elements as you like there, and they don't need to be simple. You can add entire XML documents in there.
HTH!
Upvotes: 3