Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

AEM Preicate query with cq: tags

Avatar

Level 6

I am trying to get article pages tagged with only specified cq: tags. I Followed following documentation and ACS Commons Git references.

When I execute query in predicate query console it works fine. It returns me only articles only with required tags.where as when I run query in java code. I get search results of all pages.

Please advise which I am missing.

path=/content/apples/en

type=cq:Page

property=@jcr:content/sling:resourceType

property.value=apples/components/page/article

tagid.property=jcr:content/cq:tags

tagid.1_value=namespace-a:some/tag

tagid.2_value=namespace-a:some/other/tag

orderby=@jcr:content/date

orderby.sort=desc

p.offset=0

p.limit=-1

// Tag Predicate - this has been moved into an impl package so Javadocs are not generated for it.

        map.put("tagid.property", "jcr:content/cq:tags"); // Default is 'cq:tags'

        map.put("tagid.1_value", "namespace-a:some/tag"); // Note the #_ prefix for values is required.

        map.put("tagid.2_value", "namespace-a:some/other/tag");

https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/ad...

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/querybuilder-predicate-referen...

Thank You

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Can you try with below query

path=/content/we-retail

type=cq:Page

orderby=@jcr:score

orderby.sort=desc

1_property=jcr:content/cq:tags

1_property.1_value=we-retail:equipment

1_property.2_value=we-retail:season/summer

2_property=jcr:content/sling:resourceType

2_property.value=weretail/components/structure/page

orderby=@jcr:content/date

orderby.sort=desc

6 Replies

Avatar

Community Advisor

Please check Query Builder API

You may need to update your code

map.put("tagid.property", "jcr:content/@cq:tags");

Avatar

Correct answer by
Community Advisor

Can you try with below query

path=/content/we-retail

type=cq:Page

orderby=@jcr:score

orderby.sort=desc

1_property=jcr:content/cq:tags

1_property.1_value=we-retail:equipment

1_property.2_value=we-retail:season/summer

2_property=jcr:content/sling:resourceType

2_property.value=weretail/components/structure/page

orderby=@jcr:content/date

orderby.sort=desc

Avatar

Level 3

Hi,

you can try something like this

1_tagid.property=jcr:content/cq:tags

1_tagid.1_value=we-retail:equipment

1_tagid.2_value=we-retail:season/summer

Avatar

Level 2

Hi Arun,

Im getting all the pages with cqtag "jurassicworldfacts:featured"(since i have that tag added to pages). Now i dont have a tag called "jurassicworldfacts:test".

If i give that value in the below query im getting all the results(pages). ideally i should not get any results since i dont have that tag at all.

path=/content/mobile-apps

path.self=false

type=cq:PageContent

tagid.property=cq:tags

tagid.1_value=jurassicworldfacts:test

Am i missing something here?

Can you please help me on this?

Avatar

Community Advisor

Hi,

Try below:

path=/content/mobile-apps

path.self=false

type=cq:Page

property=jcr:content/cq:tags

property.value=jurassicworldfacts:featured