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
Solved! Go to Solution.
Views
Replies
Total Likes
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!
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.
hope this will help.
Umesh Thakur
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!
Views
Likes
Replies
Views
Likes
Replies