我想搜索整个内容树,而不是在其基础上具有“请勿搜索”属性的特定树。
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/