AEM查询构建器:搜索多个属性 [英] AEM query builder: search multiple properties
本文介绍了AEM查询构建器:搜索多个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在给定节点下列出一个以上属性的所有属性和相应值.
How can I list all the properties and respective values for more than one property under a give node.
例如,下面的代码,我只能搜索一个属性.但是我需要搜索10个不同的属性(alttext,img,promos等),并为其获取相应的值(如果存在).
For example, the below code, I could search for one property only. But I need to search for 10 different property(alttext, img, promos.. etc) and get respective values(if exist) for it.
Map<String, String> map = new HashMap<String, String>();
map.put(TYPE_PREDICATE, "nt:base");
map.put(PATH_PREDICATE, printAttachmentJsonNodePath);
map.put("property", "fileReference");
map.put("p.excerpt", "true");
map.put(SEARCH_LIMIT_PREDICATE, "-1");
Query query = queryBuilder.createQuery(PredicateGroup.create(map),
resourceResolver.adaptTo(Session.class));
SearchResult result = query.getResult();
for (Hit hit : result.getHits()) {
String path = hit.getPath();
Resource resourceHit = resourceResolver.getResource(path);
Node node = resourceHit.adaptTo(Node.class);
String fileReference = node.getProperty("fileReference").getString();
System.out.println(fileReference);
}
推荐答案
您可以为多个属性使用数字前缀:
you can use numerical prefixes for multiple properties:
map.put("1_property", "jcr:content/cq:template");
map.put("1_property.value", "/apps/geometrixx/templates/homepage");
map.put("2_property", "jcr:content/jcr:title");
map.put("2_property.value", "English");
这是文档
这篇关于AEM查询构建器:搜索多个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文