marklogic - 如何获取搜索:suggestion from multiple range elements source as default-suggestion-source option

标签 marklogic marklogic-8

我的 MarkLogic 数据库中的 xml 示例如下所示

<metadata>
      <title>first title</title>
      <author>gorge k</author>
      <location>London</location>
</metadata>

我在 titleauthorlocation 上设置了范围索引。我想在所有元素而不是任何单个元素上创建默认搜索:建议源。

在搜索:选项中,我只有标题作为默认建议源选项,如下所示

<default-suggestion-source>
  <range collation="http://marklogic.com/collation/" 
      type="xs:string">
    <element ns="" name="title"/>
  </range>
</default-suggestion-source>

现在我想在上面的默认建议源选项中添加authorlocation

我尝试使用此配置添加作者:

<default-suggestion-source>
  <range collation="http://marklogic.com/collation/" 
      type="xs:string">
    <element ns="" name="title"/>
  </range>
  <range collation="http://marklogic.com/collation/" 
      type="xs:string">
    <element ns="" name="author"/>
  </range>
</default-suggestion-source>

但出现以下错误:

[1.0-ml] XDMP-ARGTYPE: (err:XPTY0004) fn:string((attribute{fn:QName("","collation")}{"http://marklogic.com/collation/"}, attribute{fn:QName("","collation")}{"http://marklogic.com/collation/"})) -- arg1 is not of type item()?

有人建议如何实现这一目标吗?

最佳答案

您可以将建议源设置为 refer to a constraint 。您可以将约束设置为 field, based on the three elements you're interested in 。设置字段范围索引和搜索选项,如下所示,我认为这应该可行。

<search:options xmlns="http://marklogic.com/appservices/search">
  <constraint name="suggestions">
    <range type="xs:string" collation="http://marklogic.com/collation/">
      <field name="suggest-field"/>
    </range>
  </constraint>
  <default-suggestion-source ref="suggestions" />
</search:options>

关于marklogic - 如何获取搜索:suggestion from multiple range elements source as default-suggestion-source option,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40766956/

相关文章:

xquery - MarkLogic - 扩展搜索,返回特定对象节点

xquery - 当我尝试更新节点时,出现错误 "Cannot Update constructed nodes"

xquery - MarkLogic 的 "xdmp:collection-delete"是如何工作的?

docker - 在Ubuntu 16.04中创建Marklogic Docker实例以暴露端口

marklogic - 字段范围索引为空

javascript - Marklogic 是否有编写 javascript 代码的框架?

marklogic - 使用 MLCP 复制数据时出现异常

xpath - 在 MarkLogic 上的 XQuery 中实现自然排序

马克逻辑 8 : Count documents per collection and/or directory

xquery - MarkLogic 8 - XQuery - cts 查询以按值查找文档属性