如何在QueryBuilder查询中添加“不在哪里” [英] How do I add a 'where not' to a QueryBuilder Query

查看:123
本文介绍了如何在QueryBuilder查询中添加“不在哪里”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想搜索整个内容树,但不搜索基数具有请勿搜索属性的特定树状目录。

I want to search the entire content tree but not specific tress that have a 'Do Not Search' property at their base.

查询生成器API 页未引用AND和OR以外的任何内容。

The Query Builder API page does not reference anything besides AND and OR.

是否可以从搜索中排除路径,还是只能明确包含路径?

Is it possible to exclude paths from the search or can I only explicitly include paths?

前三个行是 / content AND / content / path / es。我想要 / content AND NOT(/ content / path / es)

The first three lines are "/content AND /content/path/es". I want "/content AND NOT(/content/path/es)"

map.put("group.1_path", "/content");
map.put("group.2_path", "/content/path/es");
map.put("group.p.or","false");

我已经尝试了下两个true和false,但它们没有效果。

I have tried the next two both true and false and they have no effect.

map.put("group.2_path.p.not", "true");
map.put("group.2_path.not", "true");
map.put("group.2_path", "not('/content/path/es')");

我找不到任何提及 not或!的其他名称的文档

I can't find any documentation that mentions any other name that 'not' or '!' might be used instead.

推荐答案

是的。

您可以使用属性谓词评估程序排除具有某些属性的页面。

You can exclude the pages with certain properties using the property predicate evaluator.

例如如果要排除在其jcr:content节点中具有 donotsearch属性的页面,则可以使用 exists

For ex. If you want to exclude pages which have the property "donotsearch" in its jcr:content node, then you can query it using property operation as exists

map.put("path", "/content/geometrixx/en/toolbar");
map.put("type", "cq:Page");
/* Relative path to the property to check for */
map.put("property", "jcr:content/donotsearch"); 
/* Operation to perform on the value of the prop, in this case existence check */
map.put("property.operation", "exists"); 
/* Value for the prop, false = not, by default it is true */
map.put("property.value", "false"); 

这将导致以下XPath查询

This would result in the following XPath Query

/jcr:root/content/geometrixx/en/toolbar//element(*, cq:Page)
[
not(jcr:content/@donotsearch) 
]

但是如果您想排除该属性具有特定价值的页面donotsearch,那么您可以更改上面的查询,如下所示

But in case you would like to exclude pages with certain value for the property donotsearch, then you can change the above query as shown below

map.put("property", "jcr:content/donotsearch"); //the property to check for
map.put("property.operation", "equals"); // or unequals or like etc..
map.put("property.value", "/*the value of the property*/");

您可以通过引用文档

这篇关于如何在QueryBuilder查询中添加“不在哪里”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆