按 search:search 中的分面数排序

Sorting on facet count in search:search

我想根据分面数对结果进行排序。我怎样才能在 search:search 中做到这一点?

截至目前,我正在使用此查询 -

let $options := 
<options xmlns="http://marklogic.com/appservices/search">
  <return-metrics>false</return-metrics>
  <return-facets>true</return-facets>
  <return-results>false</return-results>
  <additional-query>{cts:query($cts-query)}</additional-query>
  <constraint name="decade">
    <range type="xs:dateTime" facet="true">          
      <bucket lt="2002-01-01T00:00:00Z" ge="2001-01-01T00:00:00Z" name="2001">2001</bucket>
      <bucket lt="2003-01-01T00:00:00Z" ge="2002-01-01T00:00:00Z" name="2002">2002</bucket>
      <bucket lt="2004-01-01T00:00:00Z" ge="2003-01-01T00:00:00Z" name="2003">2003</bucket>
      <bucket ge="2004-01-01T00:00:00Z" name="2004">2004</bucket>
      <facet-option>limit=10</facet-option>
      <element ns="http://iddn.icis.com/ns/core" name="released-on"/>
    </range>
  </constraint>
  <operator>
    <state>
      <sort-order direction="descending" type="xs:integer">
        <score/>
      </sort-order>
    </state>
  </operator>
</options>

let $date-seq := search:search("*", $options)
return $date-seq

我想更改选项以便我可以按方面计数对方面结果进行排序。

还没有用桶试过这个,但通常我认为你会添加 facet-options "frequency-order" 和 "descending":

<constraint name="decade">
  <range type="xs:dateTime" facet="true">          
    <bucket lt="2002-01-01T00:00:00Z" ge="2001-01-01T00:00:00Z" name="2001">2001</bucket>
    <bucket lt="2003-01-01T00:00:00Z" ge="2002-01-01T00:00:00Z" name="2002">2002</bucket>
    <bucket lt="2004-01-01T00:00:00Z" ge="2003-01-01T00:00:00Z" name="2003">2003</bucket>
    <bucket ge="2004-01-01T00:00:00Z" name="2004">2004</bucket>
    <facet-option>limit=10</facet-option>
    <facet-option>frequency-order</facet-option>
    <facet-option>descending</facet-option>
    <element ns="http://iddn.icis.com/ns/core" name="released-on"/>
  </range>
</constraint>