0

我需要安排facets为(fc=Type, Topic, Year, Editor

但是方面的顺序是基于命名概念为Editor, Topic, Type, Year(按名称升序排列)

我应该用什么方式订购它?

4

1 回答 1

0

我找到了订购方面的解决方案:

declare variable $par as element() :=  <params xmlns="http://www.marklogic.com/apa/params">
<fc>Type,Topic,Year,Editor</fc>
<start>0</start>
<rows>10</rows>
<debug>false</debug>
<results>true</results>
<facet>true</facet> 
</params>;

let $data := "xml data in search:search format"
let $spans := xs:string($params/p:fc)              
let $value := fn:tokenize($spans,",")
let $fc := for $x in $value
           return $val
let $facet := $data/search:facet
let $facets := for $facetValue in $facet
               let $label := fn:string($facetValue/@name)
               let $value := fn:tokenize($label,"L")
               order by fn:index-of($fc, $value)
               return $facetValue
return $facets

现在,$spans我们得到用户给出的分面值,并使用$data我们得到数据中的分面值。然后通过使用变量$facets,我们按指定的顺序排列它们。

于 2013-04-25T12:55:57.873 回答