1
votes

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 -

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

1

1 Answers

1
votes

Try path.exact=true Below is a example

without path.exact=true

type=cq:Page
path=/content/wkndmuzik/us/en

output: enter image description here

With path.exact=true

type=cq:Page
path=/content/wkndmuzik/us/en
path.exact=true

Output: enter image description here

path.exact=true : If true exact path is matched, if false all descendants are included.

For other predicates on querybuider api visit the blog of Hashim Khan