如何在短语上使用MarkLogic同义词库API?

如何在短语上使用MarkLogic同义词库API?,marklogic,thesaurus,Marklogic,Thesaurus,在Marklogic中,我们可以扩展搜索以包括同义词库中的术语以及搜索中输入的术语 xquery version "1.0-ml"; import module namespace thsr="http://marklogic.com/xdmp/thesaurus" at "/MarkLogic/thesaurus.xqy"; cts:search( doc("/Docs/hamlet.xml")//LINE, thsr:expand( cts:word-query("weary"),

在Marklogic中,我们可以扩展搜索以包括同义词库中的术语以及搜索中输入的术语

xquery version "1.0-ml";
import module namespace thsr="http://marklogic.com/xdmp/thesaurus" at "/MarkLogic/thesaurus.xqy";

cts:search(
doc("/Docs/hamlet.xml")//LINE,
thsr:expand(
    cts:word-query("weary"), 
    thsr:lookup("/myThsrDocs/thesaurus.xml", "weary"),
    (), 
    (), 
    () )
)
问题是如何支持以下情况:

  • 苹果和橘子
  • 苹果不是桔子
  • 苹果橙
  • 苹果+桔子
  • 表格:10-K
  • co:苹果
  • 苹果橙色表格:[10-K]
  • “苹果和橘子”
  • 苹果橙

我不认为同义词表的扩展适用于这些情况

取而代之的是,考虑使用搜索API和扩展语法来包括布尔运算符上的变体:

http://docs.marklogic.com/guide/search-dev/search-api#id_44520

到map窗体:和Co:同样的索引,再次考虑使用搜索API和定义相同索引的多个约束:

http://docs.marklogic.com/guide/search-dev/search-api#id_95820

使用
search:parse
解析查询字符串,生成cts:queryxml。然后使用递归的
typeswitch
函数遍历XML。在
cts:word
cts:word
术语上使用同义词表扩展