Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort an path range indexed element?

I have an element DateTimeList with PathRangeIndex for its first child element as follows:

/ResultPage/DateTimeList/DateTime[1]

Usually we sort an element with attribute as follows:

<sort-order type="xs:string" direction="ascending">
    <element ns="" name="div"/>
    <attribute ns="" name="order"/>
</sort-order>

Is there any similar way to sort DateTimeList element, using its first child element (using the path-range-index). I tried as follows:

<sort-order direction="ascending" type="xs:dateTime">
   <path-index>/ResultPage/DateTimeList/DateTime[1]</path-index>
</sort-order><sort-order><score/></sort-order></state></operator>

But got the result with no change as follows:

<DateTimeList>
   <DateTime>2014-05-07T10:26:00</DateTime>
</DateTimeList>
<DateTimeList>
   <DateTime>2013-12-01T00:00:00</DateTime>
   <DateTime>2014-05-01T00:00:00</DateTime>
   <DateTime>2014-12-01T00:00:00</DateTime>
</DateTimeList>
<DateTimeList>
   <DateTime>2013-09-01T10:32:42</DateTime>
</DateTimeList>
<DateTimeList>
   <DateTime>2014-05-30T00:00:00</DateTime>
   <DateTime>2015-05-30T00:00:00</DateTime>
</DateTimeList >

Thanks.

like image 740
Sofia Avatar asked Sep 25 '13 07:09

Sofia


Video Answer


1 Answers

The current releases of MarkLogic Search API actually don't support sorting by path-index. However you have constructed an expression that will work once that support is in the product. There are plans to introduce it.

I'd recommend using search:check-options($options) to see whether or not your options are valid. I believe in this case check-options will report that the node is not valid.

like image 52
grechaw Avatar answered Sep 19 '22 17:09

grechaw