Hi Brent,

 

Had to use a distinct-values() but since this is working with an index
should still be quick and avoid tree cache errors:

 

for $d in
fn:distinct-values(xs:date(cts:element-values(xs:QName('timestamp'))))

 

and able to use a filter on the query:

 

cts:element-value-query(xs:QName("timestamp"), concat(xs:string($d), '*'))

 

Thanks for the help!

 

Gary Larsen

Envisn Inc.

508 259-6465

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Brent Hartwig
Sent: Monday, February 18, 2013 3:05 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] range index on timestamp for unique
date

 

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: [email protected]
[mailto:[email protected]] 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
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to