在搜索中对构面计数进行排序:搜索

时间:2015-10-19 10:15:25

标签: xquery marklogic faceted-search marklogic-8

我想根据方面计数对结果进行排序。我怎样才能在搜索中搜索:搜索?

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

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

我想更改选项,以便我可以通过构面计数对构面结果进行排序。

1 个答案:

答案 0 :(得分:3)

没有尝试使用存储桶,但通常我认为你会添加facet-options“频率顺序”和“降序”:

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