How to put dynamic date filter in TDE?

Viewed 22

In "context" how to use date function? I want to keep the triples only for last 10 days of the doc ingested in ML.

<template xmlns="http://marklogic.com/xdmp/tde">
  <context>/MedlineCitation[createDate > ( fn:currentDateTime() - xs:dayTimeDuration('P10D')]</context>
  <triples>
    <triple>
      <subject>
        <val>sem:iri(concat(ForeName,' ',LastName))</val>
      </subject>
      <predicate>
        <val>sem:iri('authored')</val>
      </predicate>
      <object>
        <val>xs:string(../../ArticleTitle)</val>
      </object>
    </triple>
  </triples>
</template>
1 Answers

The function is fn:current-dateTime(), not fn:currentDateTime(), and you are missing the ending ):

/MedlineCitation[createDate > ( fn:current-dateTime() - xs:dayTimeDuration('P10D') )]

However, after correcting the code you will then find that it returns XDMP-UNINDEXABLEPATH.

There are restrictions and limitations for what are allowable expressions and functions for an indexable path expression. See: https://docs.marklogic.com/guide/xquery/xpath#id_18473

For a list of Functions Callable in Predicate Expressions, see: https://docs.marklogic.com/guide/xquery/xpath#id_51541

Related