tagsearch with QueryBuilder is not working from the dispatcher | Community
Skip to main content
Level 2
January 31, 2024
Solved

tagsearch with QueryBuilder is not working from the dispatcher

  • January 31, 2024
  • 2 replies
  • 535 views

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?

 

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 Juan_CarlosRa

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

2 replies

Kamal_Kishor
Community Advisor
Community Advisor
January 31, 2024

@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-in-aem-search-query-builder-while-tag/m-p/266285

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

 

Juan_CarlosRaAuthorAccepted solution
Level 2
January 31, 2024

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