我正在使用MarkLogic同义词功能,并且在传递thsr.lookup()
中的一个同义词时很难获取同义词条目。
例如:我在数据库中的thesuarus条目为
<entry xmlns="http://marklogic.com/xdmp/thesaurus">
<term>Car</term>
<part-of-speech>noun</part-of-speech>
<synonym>
<term>Ford</term>
<part-of-speech>noun</part-of-speech>
</synonym>
<synonym>
<term>automobile</term>
<part-of-speech>noun</part-of-speech>
</synonym>
<synonym>
<term>Fiat</term>
<part-of-speech>noun</part-of-speech>
</synonym>
现在,当我像这样执行函数时:
thsr.lookup('/thesaurusDoc.xml', 'Car')
我如期得到了上面的entry元素。
但是当我尝试通过同义词查找时,我会说:
thsr.lookup('/thesaurusDoc.xml', 'Fiat')
它不会返回任何内容。
如果同义词功能不支持通过同义词查找,你能告诉我我在这里做错了什么吗,并提出任何替代方案?
注意:我使用的是Marklogic服务器端Javascript函数,ML版本是9.0-8.1
我希望得到的结果是entry
元素。
发布于 2019-06-27 06:52:33
下面的查找是否更接近于满足要求?
thsr.queryLookup('/thesaurusDoc.xml', cts.wordQuery('Fiat'))
另请参阅https://docs.marklogic.com/thsr.queryLookup
希望这能有所帮助,
发布于 2019-06-27 18:08:29
您需要一个反向查找,但这从未实现过。不过,您自己浏览同义词库并不困难。对于精确匹配,您可以这样做:
doc("/thesaurusDoc.xml")
/thsr:thesaurus/thsr:entry
[thsr:synonym/thsr:term eq "Fiat"]
或者,如果您想要使用查询:
doc("/thesaurusDoc.xml")
/thsr:thesaurus/thsr:entry
[cts:contains(thsr:synonym/thsr:term, cts:word-query("Fiat"))]
哈!
https://stackoverflow.com/questions/56756757
复制相似问题