我的 MarkLogic 数据库中的 xml 示例如下所示
<metadata>
<title>first title</title>
<author>gorge k</author>
<location>London</location>
</metadata>
我在 title
、author
和 location
上设置了范围索引。我想在所有元素而不是任何单个元素上创建默认搜索:建议源。
在搜索:选项中,我只有标题作为默认建议源选项,如下所示
<default-suggestion-source>
<range collation="http://marklogic.com/collation/"
type="xs:string">
<element ns="" name="title"/>
</range>
</default-suggestion-source>
现在我想在上面的默认建议源选项中添加author
和location
。
我尝试使用此配置添加作者
:
<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/