Resolving Tags in AEM6.5 | Community
Skip to main content
Level 6
October 11, 2023
Solved

Resolving Tags in AEM6.5

  • October 11, 2023
  • 1 reply
  • 557 views

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 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aanchal-sikka

Hello @anasustic 

 

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

1 reply

aanchal-sikka
Community Advisor
aanchal-sikkaCommunity AdvisorAccepted solution
Community Advisor
October 11, 2023

Hello @anasustic 

 

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

Aanchal Sikka
anasusticAuthor
Level 6
October 11, 2023

Thank you so very much @aanchal-sikka That was it!