1

我正在使用 MarkLogic 同义词库功能,并且在将同义词之一传递给thsr.lookup().

例如:我在数据库中的同义词库条目为

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

我按预期得到了上面的条目元素。

但是当我尝试通过同义词查找时,说:

thsr.lookup('/thesaurusDoc.xml', 'Fiat')

它不返回任何东西。

如果同义词库功能不支持通过同义词进行查找,您能告诉我我在这里做错了什么并提出任何替代方案吗?

注意:我使用 Marklogic Server Side Javascript 函数,ML 版本是 9.0-8.1

我希望得到这个entry元素作为结果。

4

2 回答 2

0

您需要反向查找,但这从未实现。不过,自己浏览同义词库并不难。对于完全匹配,您可以执行以下操作:

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"))]

于 2019-06-27T10:08:29.403 回答
0

以下查找是否更接近满足要求?

thsr.queryLookup('/thesaurusDoc.xml', cts.wordQuery('Fiat'))

另请参阅https://docs.marklogic.com/thsr.queryLookup

希望有帮助,

于 2019-06-26T22:52:33.007 回答