You could use document-properties for this - here's a simplistic example:
for $d in doc() order by $d/property::prop:last-modified return xdmp:node-uri($d)
Note that this won't scale - it just illustrates the use of document properties.
Depending on the problem you're trying to solve, you could also iterate over the results from a cts:search using a similar technique.
You could also use the search API and pass the properties query in as an additional query or use xdmp:document-properties() as a searchable expression...
Having said that, I noticed you wanted to sort by creation time, not modified time. You could add the creation time as additional XML metadata to the document and set up a process which adds the dateTime stamp to the doc at the point where it's loaded into the database. Add an xs:dateTime range index to the element if you want to make it more performant...
3 comments:
How to sort all documents as per the creation time ?
Sir any solution pls... ?
Hi,
You could use document-properties for this - here's a simplistic example:
for $d in doc()
order by $d/property::prop:last-modified
return xdmp:node-uri($d)
Note that this won't scale - it just illustrates the use of document properties.
Depending on the problem you're trying to solve, you could also iterate over the results from a cts:search using a similar technique.
You could also use the search API and pass the properties query in as an additional query or use xdmp:document-properties() as a searchable expression...
Having said that, I noticed you wanted to sort by creation time, not modified time. You could add the creation time as additional XML metadata to the document and set up a process which adds the dateTime stamp to the doc at the point where it's loaded into the database. Add an xs:dateTime range index to the element if you want to make it more performant...
Post a Comment