Hi, Gary,

You could cast from dateTime to date, using the range index:

xquery version "1.0-ml";
xs:date(
   cts:element-values(
      fn:QName(
         "http://www.rsuitecms.com/rsuite/ns/materialized-view";,
         "last-modified")))

I thought perhaps one could create two indexes against the same data with 
different, yet compatible scalar types.  But when I defined another index of 
type date against this data, cts:element-values() returned an empty sequence.

-Brent

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Gary Larsen
Sent: Monday, February 18, 2013 2:46 PM
To: General MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] range index on timestamp for unique date

Hi,

The documents I'm after have a timestamp element formatted like this:  
<timestamp>2013-02-13T14:51:19.373</timestamp>

I need a list of distinct dates so that I can run a query on each date.  What 
I'm trying to avoid is using distinct-values() on the full result set as that 
can be very large (and cause tree cache errors):
                fn:distinct-values(for $a in $actions return 
xs:date(xs:dateTime($a/nv:timestamp)))

Is it possible to make a range or field index with a function to convert to 
date?  Tried a range index with scalar type of date but cts:element-values() 
returns distinct date-time values.  The only solution I can think of is to 
insert a date element all the docs.

Thanks for any advice.

Gary

_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to