aem - 如何将 'where not' 添加到 QueryBuilder 查询

标签 aem query-builder

我想搜索整个内容树,而不是在其基础上具有“请勿搜索”属性的特定树。

Query Builder API除了 AND 和 OR 之外,页面不引用任何内容。

是否可以从搜索中排除路径,或者我是否可以只明确包含路径?

前三行是“/content AND/content/path/es”。我想要“/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都没有效果。

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

我找不到任何提及“不”或“!”的任何其他名称的文档可能会被使用。

最佳答案

是的,这是可能的。但不完全是您尝试的方式。

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

例如。如果你想排除在其 jcr:content 节点中具有属性“donotsearch”的页面,那么你可以使用属性操作查询它作为 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 查询

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

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

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*/");

您可以通过引用 docs 找到很多关于查询的其他信息。 .

关于aem - 如何将 'where not' 添加到 QueryBuilder 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22510025/

相关文章:

aem - 如何限制组件每页仅添加一次

aem - 以编程方式设置 cq :tags save blank value in the node in AEM

angularjs-directive - Ng-repeat 在 Sightly 中

laravel - 我已将 Laravel 查询生成器分配给一个变量。使用时会发生变化

javascript - 无法访问 AEM 中 javascript 内的 html 变量

java - com.day.cq.search.impl.SimpleSearchImpl 是否公开了 addPredicate() 方法?

php - 什么是可以在 PHP 5.3 上解析和重建 SQL 查询的优秀查询生成器?

java - 使用 4.48 版构建 ORMLite 查询时出现问题

php - 查询生成器并使用 laravel 从一个表中查找另一个表中不存在的记录

c# - 使用 SqlKata 在 sql 中按月份名称分组