What should be the query to fetch all the pages which are having a specific word or start with that word in AEM query builder ? | Community
Skip to main content
Level 3
February 14, 2024
Solved

What should be the query to fetch all the pages which are having a specific word or start with that word in AEM query builder ?

  • February 14, 2024
  • 4 replies
  • 3588 views

In my site i have a search bar on my UI where user can search for any specific page which starts with a letter or having that word in the page name. let suppose i have these pages "Check user details", "Check employee details", "User checkout timing details". And now user is searching with the keyword check, so it should return all the pages having word "check"

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 Mahedi_Sabuj

You can utilize the nodename predicate to search for pages by their name.

type = cq:Page path = /content/aem-demo nodename = *check* p.limit = -1

https://experienceleague.adobe.com/docs/experience-manager-65/content/implementing/developing/platform/query-builder/querybuilder-predicate-reference.html?lang=en#nodename  

4 replies

TarunKumar
Community Advisor
Community Advisor
February 14, 2024

Hi @monish_gavali ,

In your query builder map you can use fulltext search functionality.
Something like below:

map.put("path", "/content/<sample-path>"); //searchText would be your variable or user input from search bar map.put("fulltext", searchText); map.put("type", "cq:Page");

 

Thanks
Tarun

Community Advisor
February 14, 2024

Hi @monish_gavali

Please check below link for exactly similar use case. You have to use full text search query but it needs to be tweaked slightly.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/fulltext-in-query-doesn-t-work-for-partial-search-term/m-p/402524

 

Mahedi_Sabuj
Community Advisor
Mahedi_SabujCommunity AdvisorAccepted solution
Community Advisor
February 14, 2024

You can utilize the nodename predicate to search for pages by their name.

type = cq:Page path = /content/aem-demo nodename = *check* p.limit = -1

https://experienceleague.adobe.com/docs/experience-manager-65/content/implementing/developing/platform/query-builder/querybuilder-predicate-reference.html?lang=en#nodename  

Mahedi Sabuj
Level 3
February 14, 2024

It worked for me but what if i want to create some query in the below thing.

 

Mahedi_Sabuj
Community Advisor
Community Advisor
February 14, 2024

Equivalent XPath Query

/jcr:root/content/aem-demo//element(*, cq:Page) [ (jcr:like(fn:name(), '%check%')) ]

You can refer to this link for more details.
https://experienceleague.adobe.com/docs/experience-manager-65/assets/JCR_query_cheatsheet-v1.1.pdf?lang=en

 

 

Mahedi Sabuj
Imran Khan
Community Advisor
Community Advisor
February 14, 2024
kautuk_sahni
Community Manager
Community Manager
February 16, 2024

@monish_gavali Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni