Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
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



Arun Patidar

View solution in original post

12 Replies

Avatar

Community Advisor

Please check Query Builder API

You may need to update your code

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



Arun Patidar

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



Arun Patidar

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



Arun Patidar

Avatar

Level 3

Hi @arunpatidar 

What should be the query if i want to return the tag value for CF's under certain paths..

Avatar

Community Advisor

I think you just need to change the path predicate

e.g.

path=/content/dam/my-project/content-fragment-path/xyz



Arun Patidar

Avatar

Level 3

Hi @arunpatidar 

path=/content/dam/my-project/content-fragment/seema

type=dam:Asset

property=jcr:content/cq:tags

Is it correct?

I want to return the value of tags associated with fragments under folder seema

Avatar

Community Advisor

path=/content/dam/my-project/content-fragment/seema

type=dam:Asset

property=jcr:content/metadata/cq:tags

 

 



Arun Patidar

Avatar

Community Advisor

you have to specify that, you want tags
http://localhost:4502/bin/querybuilder.json?p.hits=selective&p.limit=-1&p.properties=jcr%3apath%20jc... 

 

path=/content/dam/we-retail/en/faqs/shipping-and-returns
type=dam:Asset
p.hits=selective
p.properties=jcr:path jcr:content/metadata/cq:tags
p.limit=-1


Arun Patidar