Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

tagsearch with QueryBuilder is not working from the dispatcher

Avatar

Level 2

I have the following

 

String content = "/content/site";
String text = get("text", String.class);
ResourceResolver resolver = getResourceResolver();
Session session = resolver.adaptTo(Session.class);
QueryBuilder builder = getSlingScriptHelper().getService(QueryBuilder.class);
Map<String, String> queryTag = new HashMap<>();
map.put("path", content);
map.put("tagsearch", text);
map.put("p.offset",0);
map.put("p.limit",-1);
Query query = builder.createQuery(PredicateGroup.create(queryTag), session);
SearchResult result = query.getResult();
LOG.debug("Total: " + result.getTotalMatches());

 

In my local environment, and also in the development environment when I search without going through the dispatcher, it finds the content through the tag without any issues. However, when I search through the dispatcher, it doesn't return any results. When I query the site through the dispatcher, the log shows 0 results, but when the dispatcher is bypassed, it does return results. The strange thing is that when I search by fulltext instead of tag, searching for content through the dispatcher does work. Is there any functionality in the dispatcher that could be blocking the search through tagsearch?

 

1 Accepted Solution

Avatar

Correct answer by
Level 2

I have corrected it; I forgot to give read permissions to the 'everyone' user for the tags.

View solution in original post

2 Replies

Avatar

Community Advisor

@Juan_CarlosRa: Are you seeing results on publisher instance? (I assume your tags are published as well).
I see a similar issue where it does work with tagsearch, please refer: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-include-tag-names-i...

Also, what is the value you getting from this line.

String text = get("text", String.class);

Alternatively, you cna try with a slightly different approach and search with the property which stores the tags on your pages i.e jcr:content/cq:tags for eg

https://stackoverflow.com/questions/39782097/querybuilder-search-for-only-single-tag

 

Avatar

Correct answer by
Level 2

I have corrected it; I forgot to give read permissions to the 'everyone' user for the tags.