Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Marklogic 如何组合cts:search可搜索表达式和cts:not查询?_Marklogic - Fatal编程技术网

Marklogic 如何组合cts:search可搜索表达式和cts:not查询?

Marklogic 如何组合cts:search可搜索表达式和cts:not查询?,marklogic,Marklogic,我一直在使用cts:search和searchable expression从XML文档中提取特定元素。例如: 文件: <book> <recipe> <ingredients>cinnamon, peppermint</ingredients> <instruction/> </recipe> <recipe> <ingredients>sugar, pepper

我一直在使用
cts:search
searchable expression从XML文档中提取特定元素。例如:

文件:

<book>
  <recipe>
    <ingredients>cinnamon, peppermint</ingredients>
    <instruction/>
  </recipe>
  <recipe>
    <ingredients>sugar, peppermint</ingredients>
    <instruction/>
  </recipe>
  <recipe>
    <ingredients>coconut oil</ingredients>
    <instruction/>
  </recipe>
</book>
结果:

<recipe>
  <ingredients>cinnamon, peppermint</ingredients>
  <instruction>
  </instruction>
</recipe>
<recipe>
  <ingredients>sugar, peppermint</ingredients>
  <instruction>
  </instruction>
</recipe>
查看查询计划,我的理解是,
cts:notquery
在过滤之前应用于片段(文档)级别,因此上述文档被彻底删除。如果这是正确的,那么这种行为是有意义的


尽管如此,我仍然想知道这是否能以某种方式实现。谢谢

不鼓励使用与根节点不匹配的可搜索表达式

更复杂的可搜索表达式的一个问题是,一个小的更改可能会使搜索需要过滤

这就是SJS版本的search不支持可搜索表达式的原因之一

建议的方法是

  • 使用每个对象/行的单独文档对文档进行建模(本例中为配方)——这消除了未过滤搜索中匹配两个不同对象中部分条件的误报可能性
  • 使用
    cts:query
    参数进行匹配,并对返回的文档使用XPath提取节点
  • 根据查询,根据需要将对象组合到列表中

希望这能有所帮助,

我想cts有什么特别之处:不是质疑假阳性变成假阴性。因此,即使是过滤搜索也不起作用。你认为是这样吗?@FanLi——是的,not查询会阻止文档通过索引解析阶段,因此过滤没有帮助。
<recipe>
  <ingredients>cinnamon, peppermint</ingredients>
  <instruction>
  </instruction>
</recipe>
<recipe>
  <ingredients>sugar, peppermint</ingredients>
  <instruction>
  </instruction>
</recipe>
cts:search(//recipe, cts:parse("-cinnamon"))