我有一个元素 DateTimeList,其第一个子元素的 PathRangeIndex 如下:
/ResultPage/DateTimeList/DateTime[1]
通常我们对具有属性的元素进行如下排序:
<sort-order type="xs:string" direction="ascending">
<element ns="" name="div"/>
<attribute ns="" name="order"/>
</sort-order>
是否有任何类似的方法来排序 DateTimeList 元素,使用它的第一个子元素(使用路径范围索引)。我试过如下:
<sort-order direction="ascending" type="xs:dateTime">
<path-index>/ResultPage/DateTimeList/DateTime[1]</path-index>
</sort-order><sort-order><score/></sort-order></state></operator>
但得到的结果没有变化如下:
<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 >
谢谢。
最佳答案
当前版本的 MarkLogic Search API
实际上不支持按 path-index 排序。但是,您已经构建了一个表达式,一旦该支持在产品中就可以使用。有计划引进。
我建议使用 search:check-options($options)
来查看您的选项是否有效。我相信在这种情况下 check-options 会报告该节点无效。
关于xml - 如何对路径范围索引元素进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18998969/