Expand my Community achievements bar.

SOLVED

Resolving Tags in AEM6.5

Avatar

Level 7

When I resolve tags using the following code I get them in format: blog : something management / themeninvestments 

String QUERY2 = "SELECT * FROM [cq:Tag] AS tag WHERE (ISDESCENDANTNODE(tag, '/content/cq:tags/blog') OR ISDESCENDANTNODE(tag, '/content/cq:tags/zkb/content/blog')) AND tag.[sling:resourceType] = 'cq/tagging/components/tag'";

resourceResolverUsageService.withServiceUserResourceResolver(ServiceUser.CONTENT_READER, resolver -> {


List<String> tags = StreamUtil.iteratorStream(resolver.findResources(QUERY2, Query.JCR_SQL2))
.map(r -> r.adaptTo(Tag.class))
.map(tag -> tag.getTitlePath().toLowerCase())
.collect(Collectors.toList());
tagNames.addAll(tags);

 When I on the other hand get the tag from Sling 

sling:resourceType="cq/gui/components/coral/common/form/tagfield"

 they appear as blog:something-management/themeninvestments 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @anasustic 

 

Can you please try by switching the API from "getTitlePath"  to "getTagID()"


Aanchal Sikka

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hello @anasustic 

 

Can you please try by switching the API from "getTitlePath"  to "getTagID()"


Aanchal Sikka