Issue with excluding certain paths from search results. | Community
Skip to main content
Level 2
July 18, 2024
Solved

Issue with excluding certain paths from search results.

  • July 18, 2024
  • 1 reply
  • 661 views

Hi,

 

I need to exclude two paths from my search results and hence I have added my paths under property excludedPaths in the node: /oak:index/cqPageLucene-custom-11. But still I could see the two paths in the search results.
I have changed the reindex property to true, waited for some time so that it chnaged to false and the reindexCount got updated. Still could see the paths in search results.
Kindly help.

Best answer by aanchal-sikka

@stj_1234 

 

I would suggest formulating the query as you expect the results to be:

path=/content/my-site/us/en type=cq:Page group.1_group.p.not=true group.1_group.path=/content/my-site/us/en/services group.1_group.path.self=true group.2_group.p.not=true group.2_group.path=/content/my-site/us/en/products group.2_group.path.self=true

Src: https://sourcedcode.com/blog/aem/query-builder-api-exclude-pages-or-paths#google_vignette

 

Benefits:

  • When someone looks at the query, they know what to expect. 
  • This way the exclude paths in index are in sync with query, so changes of unexpected results reduce.

 

Also, please verify that when you do not use excludes in query, is it the custom index thats picked or any other.

 

1 reply

aanchal-sikka
Community Advisor
aanchal-sikkaCommunity AdvisorAccepted solution
Community Advisor
July 18, 2024

@stj_1234 

 

I would suggest formulating the query as you expect the results to be:

path=/content/my-site/us/en type=cq:Page group.1_group.p.not=true group.1_group.path=/content/my-site/us/en/services group.1_group.path.self=true group.2_group.p.not=true group.2_group.path=/content/my-site/us/en/products group.2_group.path.self=true

Src: https://sourcedcode.com/blog/aem/query-builder-api-exclude-pages-or-paths#google_vignette

 

Benefits:

  • When someone looks at the query, they know what to expect. 
  • This way the exclude paths in index are in sync with query, so changes of unexpected results reduce.

 

Also, please verify that when you do not use excludes in query, is it the custom index thats picked or any other.

 

Aanchal Sikka