使用AEM查询生成器检索父节点

使用AEM查询生成器检索父节点,aem,query-builder,Aem,Query Builder,我需要使用AEM查询生成器检索父节点 例如,这是我的查询: path:/content/test/us/bar 1_property:product 1_property.operation:exists 2_property:product 2_property.value:8003170008212 此查询允许我检索以下元素: 1) /content/test/us/bar/table/jcr:content/releated/product/2 2) /content/test/u

我需要使用AEM查询生成器检索父节点

例如,这是我的查询:

path:/content/test/us/bar
1_property:product
1_property.operation:exists

2_property:product
2_property.value:8003170008212
此查询允许我检索以下元素:

1) /content/test/us/bar/table/jcr:content/releated/product/2  
2) /content/test/us/bar/chair/jcr:content/releated/product/1
使用此查询,可以检索放置在/content/test/us/bar下的所有元素,这些元素包含8003170008212作为产品属性的值

从前面的要点开始,我只需要返回父项,例如:

1) /content/test/us/bar/table
2) /content/test/us/bar/chair
我可以通过编程实现我的目标,迭代结果并使用3次getParent()方法


我想知道:有没有一种方法可以通过查询生成器获得它

如果要搜索的属性始终存在于已知路径中,则可以将查询重写为

path=/content/test/us/bar
1_property=jcr:content/related/product
1_property.operation=exists

2_property=jcr:content/related/product
2_property.value=8003170008212 
这将导致

/content/test/us/bar/table
/content/test/us/bar/chair
这样可以避免在结果中循环并找到父节点

例如,我的本地环境中的以下查询

path=/content/we-retail/language-masters/en
1_property=displayMode
1_property.operation=exists

2_property=displayMode
2_property.value=singleText
导致

/content/we-retail/language-masters/en/experience/wester-australia-by-camper-van/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/arctic-surfing-in-lofoten/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/steelhead-and-spines-in-alaska/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/hours-of-wilderness/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/skitouring/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/fly-fishing-the-amazon/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/wester-australia-by-camper-van
/content/we-retail/language-masters/en/experience/arctic-surfing-in-lofoten
/content/we-retail/language-masters/en/experience/steelhead-and-spines-in-alaska
/content/we-retail/language-masters/en/experience/hours-of-wilderness
/content/we-retail/language-masters/en/experience/skitouring
/content/we-retail/language-masters/en/experience/fly-fishing-the-amazon
但是将以下查询重写为

path=/content/we-retail/language-masters/en
1_property=jcr:content/root/responsivegrid/contentfragment/displayMode
1_property.operation=exists

2_property=jcr:content/root/responsivegrid/contentfragment/displayMode
2_property.value=singleText
导致

/content/we-retail/language-masters/en/experience/wester-australia-by-camper-van/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/arctic-surfing-in-lofoten/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/steelhead-and-spines-in-alaska/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/hours-of-wilderness/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/skitouring/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/fly-fishing-the-amazon/jcr:content/root/responsivegrid/contentfragment
/content/we-retail/language-masters/en/experience/wester-australia-by-camper-van
/content/we-retail/language-masters/en/experience/arctic-surfing-in-lofoten
/content/we-retail/language-masters/en/experience/steelhead-and-spines-in-alaska
/content/we-retail/language-masters/en/experience/hours-of-wilderness
/content/we-retail/language-masters/en/experience/skitouring
/content/we-retail/language-masters/en/experience/fly-fishing-the-amazon

我刚试过,但不起作用。您向我建议的查询返回0个结果。哪一个是你的AEM版本?我的是6.2。谢谢你,从你的answear开始,我有了我的解决方案。