2013-09-25 57 views
4

我有一個元件DateTimeList與PathRangeIndex其第一個子元素如下:如何對路徑範圍索引元素進行排序?

/ResultPage/DateTimeList /日期時間[1]

通常我們如下排序與屬性的元素:

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

是否有任何類似的方式利用其樅排序DateTimeList元素, st子元素(使用path-range-index)。我試過如下:

<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 > 

感謝。

+1

您可以重新運行調試選項集http://docs.marklogic.com/guide/rest-dev/appendixb#id_57802並回報嗎? –

+0

我用調試選項集返回並得到錯誤,如下所示:XDMP-LEXVAL:xs:boolean(「」) - 無效的詞法值「」 – LSB

+0

對於尋找解決方案的其他人 - 根據以下內容使用'field': https://stackoverflow.com/a/28516625/2155673 –

回答

5

當前版本MarkLogic Search API實際上不支持通過路徑索引排序。然而,你已經構建了一個表達式,只要產品中有這種支持,它就可以工作。有計劃介紹它。

我推薦使用search:check-options($options)來查看您的選項是否有效。我相信在這種情況下,檢查選項會報告該節點無效。

+0

是的,當我用搜索檢查時,我得到了SEARCH-SCHEMAINVALID:check-options($ options)。 – LSB

0

這裏沒有足夠的信息來重現問題,但所有這些元素都在同一個文檔中?或者每個文檔有多個DateTimeList元素?

搜索和排序主要發生在文檔級別。 MarkLogic是一個面向文檔的數據庫。所以索引指向文檔,這些文檔在RDBMS表中的行就像行。

如果是這樣,考慮拆分文件。在技​​術上可以將DateTimeList分段並在//DateTimeList上添加searchable-expression。但我的經驗是,將文檔的結構設置在合適的層面上更好。

+1

4個不同的記錄給出了上面已經描述的輸出,一個文檔具有單個DateTimeList元素。 – LSB

+0

看起來像http://markmail.org/message/d2gaoim4ibdlmywr有答案。在'search.xqy'中修復之前,您必須直接調用'cts:search'來完成這項工作。該帖子還包括了在調試搜索API問題時嘗試使用「search:check-options」的出色建議。 – mblakele

相關問題