简体   繁体   中英

How to put dynamic date filter in TDE?

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM