Hello,
I have a requirement to search any content inside all the pages of a website. I have written a query like SELECT * FROM [cq:PageContent] AS content WHERE ISDESCENDANTNODE('/content/pathoftheproject') and contains(content.*, 'search_keyword') This query is searching for a keyword which is within the page content. But most of the page content is residing inside the content fragment which is referred in the page. The seach query is not performing search within the content of the page content. Is there any way that I can alter the query or write custom code to search inside the page content and the content fragment referred inside the page content?
Thanks
pjinfo
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @pjinfo,
Below is the sample query predicate set for 2 queries
One to do a full text search on Page and content fragment path (OR condition between page and fragment)
3_group.1_group.path=/content/dam/learnings/contentfragments
3_group.1_group.type=dam:Asset
3_group.2_group.path=/content/learnings
3_group.2_group.type=cq:PageContent
3_group.p.or=true
fulltext=searchtext // search param
p.limit=-1
Second to bring in the pages where the fragment (acquired in result of first query execution) is authored
path=/content/learnings
type=nt:unstructured
1_property=sling:resourceType
1_property.value=learnings/components/content/contentfragment
2_property=fragmentPath
2_property.value=/content/dam/learnings/contentfragments/sample-cf-web
p.limit=-1
Sample code with implementation using Query Builder API is added to my GITHUB repo
Assumptions:
I had similar requirement of searching the content inside content fragment inside page.
I'm not sure below will help you but I'm trying to just help :
There will be different scenarios or requirements. One of it is:
Scenario 1 : You want the pages in which there is content fragment having search keyword 'hello_world'
You can go through below points and try to implement in this way:
1) Content fragments are of type dam:Asset
2) Refine your query to search in Dam for the type dam:Asset and provide your properties and values to be searched .
3) It will provide you the let's say 5 content fragments like .. /content/dam/contentfragmentpaths
4) You can run one more query ( or you can use sub or inner query sql2 ) to find out the pages in which these 5 content fragments are referred or authored (in page)
Hope it's helpful.
Thanks
Abhishek Lakhpatre
Views
Replies
Total Likes
My question to key word contains is similar to yours. See https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/sql2-query-with-contains-d.... Will it help if you use the like operator instead of contains?
Hi @pjinfo,
Below is the sample query predicate set for 2 queries
One to do a full text search on Page and content fragment path (OR condition between page and fragment)
3_group.1_group.path=/content/dam/learnings/contentfragments
3_group.1_group.type=dam:Asset
3_group.2_group.path=/content/learnings
3_group.2_group.type=cq:PageContent
3_group.p.or=true
fulltext=searchtext // search param
p.limit=-1
Second to bring in the pages where the fragment (acquired in result of first query execution) is authored
path=/content/learnings
type=nt:unstructured
1_property=sling:resourceType
1_property.value=learnings/components/content/contentfragment
2_property=fragmentPath
2_property.value=/content/dam/learnings/contentfragments/sample-cf-web
p.limit=-1
Sample code with implementation using Query Builder API is added to my GITHUB repo
Assumptions:
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies