I'm using query builder to search for images in DAM. I use predicates to do that. I'm trying to check metadata dam:MIMEtype property, to return all nodes which starts from image/.
How can I do that?
You can use the JcrPropertyPredicateEvaluator to achieve the same.
Assuming that you are searching the path /content/dam
for all dam:Asset
's whose dam:MIMEtype
starts with image/
the query would be
path=/content/dam
type=dam:Asset
property=jcr:content/metadata/dam:MIMEtype
property.value=image/%
property.operation=like
p.limit=-1
The corresponding XPATH query would be
/jcr:root/content/dam//element(*, dam:Asset)
[
jcr:like(jcr:content/metadata/@dam:MIMEtype, 'image/%')
]
You can try executing the above query in your instance's query debugger(/libs/cq/search/content/querydebug.html
) and verify if the results are fine.
PredicateEvaluator Docs and the QueryBuilder API might provide more insights on writing queries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With