我正在使用查询生成器在 DAM 中搜索图像。我使用谓词来做到这一点。我正在尝试检查元数据 dam:MIMEtype 属性,以返回从 image/开始的所有节点。
我怎样才能做到这一点?
最佳答案
您可以使用 JcrPropertyPredicateEvaluator 来实现相同的目的。
假设您正在搜索路径 /content/dam
的所有 dam:Asset
,其 dam:MIMEtype
以 image/
开头,查询将是
path=/content/dam
type=dam:Asset
property=jcr:content/metadata/dam:MIMEtype
property.value=image/%
property.operation=like
p.limit=-1
相应的 XPATH 查询将是
/jcr:root/content/dam//element(*, dam:Asset)
[
jcr:like(jcr:content/metadata/@dam:MIMEtype, 'image/%')
]
您可以尝试在实例的查询调试器 (
/libs/cq/search/content/querydebug.html
) 中执行上述查询并验证结果是否正常。PredicateEvaluator Docs 和 QueryBuilder API 可能会提供有关编写查询的更多见解。
关于AEM Predicate - 如何检查属性是否以/包含字符串开头?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28684577/