MarkLogic 8 - sort-order by path-index

情到浓时终转凉″ 提交于 2019-12-22 05:28:13

问题


Is sort-order by path-index already supported in ML 8? I want to achieve similar to the below:

<options xmlns="http://marklogic.com/appservices/search">
  <sort-order collation="http://marklogic.com/collation/en/S1/EO/CU/MO" type="xs:string" direction="ascending">
    <path-index>attritbutes//name</path-index>
  </sort-order>
</options>

If not, is there a way to achieve this? I have several elements with the same name from different parent nodes or from the root element so I can't use just

<options xmlns="http://marklogic.com/appservices/search">
  <sort-order collation="http://marklogic.com/collation/en/S1/EO/CU/MO" type="xs:string" direction="ascending">
    <element ns="" name="name"/>
  </sort-order>
</options>

回答1:


According to the docs:

The sort-order element must have one of a single element child, a single score child, a single field child, or a single json-property child.

So you can't have a path child, but there is a way. Create a field based on the path(s) you want to use, then sort based on that field.




回答2:


There is a schema bug in 8.0-1 so that sort-order/path-index does not validate.

However, the code implements support for sort-order/path-index, so if you don't validate the options, it should work. It might be better, however, to use a field as Dave suggests so you can continue to use validation to check for errors.

The schema bug is fixed in 8.0-2.




回答3:


Yes, Create a field on 'name' element

<options xmlns="http://marklogic.com/appservices/search">
  <sort-order type="xs:string" 
              collation="http://marklogic.com/collation/" 
              direction="ascending">
    <field name="name"/>
  </sort-order>
</options>


来源:https://stackoverflow.com/questions/28516041/marklogic-8-sort-order-by-path-index

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!