Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Exclude child path from fulltext search parent path using Querybuilder OR get search hit excerpt from XPATH/JCR SQL2 query

Avatar

Avatar
Validate 1
Level 4
cqsapientu69896
Level 4

Likes

22 likes

Total Posts

76 posts

Correct Reply

4 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile

Avatar
Validate 1
Level 4
cqsapientu69896
Level 4

Likes

22 likes

Total Posts

76 posts

Correct Reply

4 solutions
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back 10
Give Back
View profile
cqsapientu69896
Level 4

10-11-2020

I want to exclude child nodes path from search path using querybuilder 

 

for example - parent folder is /content/mysite/en

 

and subfolders are

 

/content/mysite/en/testfolder1

/content/mysite/en/testfolder2

 

I want query builder to write a query to exclude these paths

 

I already looked at this question - 

https://stackoverflow.com/questions/45292778/aem-query-builder-exclude-a-folder-in-search

but grouping paths and p.not=true doesn't seem to be working as expected

 

I know it's a bit tricky to write such a query using query builder ; so I am using JCR/SQL2 query  - 

 

using 

 

SELECT * FROM [cq:Page] 
WHERE ISDESCENDANTNODE(page,'/content/mysite/en') 
AND CONTAINS(*, 'fulltext') 
AND NOT ISDESCENDANTNODE(page, '/content/mysite/en/testfolder1') 
AND NOT ISDESCENDANTNODE(page, '/content/mysite/en/testfolder2')

 

but the issue now is that We also want the search excerpt which is created automatically by querybuilder api's SearchResult's hit object - 

 

hit.getExcerpt()

 so is there a way I can get the excerpt using JCR/SQL2 query ?

 

OR is there a way I can build the exclude subfolder query using querybuilder; so that I can get excerpts from results? Both solutions will solve my case. 

 

If anyone has experience in excluding subfolder query using querybuilder; or building search excerpt using JCR/SQL2 query; or any other idea/suggestion for this case;  help will be much appreciated

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 3
MVP
Manjunath_K
MVP

Likes

140 likes

Total Posts

188 posts

Correct Reply

61 solutions
Top badges earned
Give Back 3
Give Back
Boost 50
Boost 5
Boost 3
View profile

Avatar
Give Back 3
MVP
Manjunath_K
MVP

Likes

140 likes

Total Posts

188 posts

Correct Reply

61 solutions
Top badges earned
Give Back 3
Give Back
Boost 50
Boost 5
Boost 3
View profile
Manjunath_K
MVP

11-11-2020

Hi @cqsapientu69896 

You can pass query map with properties as mentioned below to QueryBuilder API, define paths which needs to be excluded in group as highlighted below & then you can get hit.getExcerpt() from QueryBuilder search result.

 

1_property=property-name
1_property.value=property-value
path=/content/mysite/en
group.1_group.p.not=true
group.1_group.path=/content/mysite/en/testfolder1
group.1_group.path.self=true
group.2_group.p.not=true
group.2_group.path=/content/mysite/en/testfolder2
group.2_group.path.self=true

 

 

Hope this helps!

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
MVP
Umesh_Thakur
MVP

Likes

147 likes

Total Posts

157 posts

Correct Reply

53 solutions
Top badges earned
Validate 1
Applaud 25
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Validate 1
MVP
Umesh_Thakur
MVP

Likes

147 likes

Total Posts

157 posts

Correct Reply

53 solutions
Top badges earned
Validate 1
Applaud 25
Ignite 3
Ignite 1
Give Back 5
View profile
Umesh_Thakur
MVP

11-11-2020

can you check with 

 String sql= "SELECT * FROM sling:Folder WHERE jcr:path LIKE '"+path +"/%'  AND NOT jcr:path LIKE '"+path +"/%/%'";

that I got from one of the old community  you can check it on below link.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/question-regarding-query-b...

hope this will help.

Umesh Thakur