我需要将facets
安排为(fc=Type, Topic, Year, Editor
)
但是facet的顺序基于命名概念为Editor, Topic, Type, Year
(按名称按升序排列)
我应该用什么方式订购?
答案 0 :(得分: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
中,我们获得了用户给出的facet值,并使用$data
得到了数据中的facet值。然后通过使用变量$facets
,我们按照指定的顺序排列它们。