Metadata projection through TDE

tde
semantics

#1

I have a template (json format) to project triples from document’s content properties.
I also have metadatas stored on those documents, added on document creation/update with xdmp:document-insert.

How can I access to document metadata in tde template?

I tried with the following in the template:

"triples": [ {
    "subject":   { "val": "$sub" },
    "predicate": { "val": "sem:iri($pred || 'hash')" },
    "object":    { "val": "xdmp:document-get-metadata-value(fn:document-uri(fn:root(.)), 'hash')" }
}] 

with “hash” the correct name of the metadata.

It gave me the error above:

###  TDE-EVALFAILED: tde.nodeDataExtract([cts.doc("/root/0322a0e4-7e96-4112-bfe6-5f642bcd2a53.json")], [Document({"template":{"description":"Template to project triples out of ...", ...}})]) -- Eval for Object='xdmp:document-get-metadata-value(fn:document-uri(fn:root(.)), 'hash')' returns XDMP-UNDFUN: (err:XPST0017) Undefined function **xdmp:document-get-metadata-value()**

#2

Hi Clement. You were almost there!

You cannot use xdmp:document-get-metadata-value in a TDE template, but you can use xdmp:node-metadata-value. Make sure you apply it on the document node (that is, on the root of the document, like you are correctly doing to retrieve its URI):

xdmp:node-metadata-value(root(.), 'hash')

The explicit list of all functions you can use in a template is there: Template Dialect and Data Transformation Functions.

PS: The doc of xdmp:node-metadata-value says its first parameter is a string, but it really is a node.

Hope that helps.


#3

Thanks fgeorges ,

xdmp:node-metadata-value works perfectly