Default Node Depth for Site Search

jetate

22-06-2020

In using the core Search component, I have discovered that content nested in 2 levels of Layout Containers is not showing in my search results while content in only one Layout Container does show.

Is there a default setting that can be modified to pull back search results from within two nested Layout Containers or possible deeper?

 

EDIT - Answer marked correct is not the solution.

By default, the cqPageLucene oak:index only indexes 4 nodes deep (*/*/*/*). 

To increase the node depth for search, you can add additional includes under oak:index/cqPageLucene/aggregates/cq:PageContent with additional levels. By adding include4 (*/*/*/*/*) and include 5 (*/*/*/*/*/*) to my aggregates, my nested components began producing search results.

Accepted Solutions (1)

Accepted Solutions (1)

Himanshu_Singhal

MVP

22-06-2020

For the Core Search component, by default no such option available to set the search depth. 

 

SearchResultServlet servlet is responsible to get the search results and it internally run a full text search query to find the data. If it doesn't meet your requirement and you'd like to have a different set of result, then you can write your own custom servlet. 

All you need to do is write Custom servlet and modify the selector in search.html as highlighted below and it'll start calling the custom servlet. 

<form class="cmp-search__form" data-cmp-hook-search="form"
method="get" action="${currentPage.path @ addSelectors=['searchresults'], extension='json', suffix = search.relativePath}"
autocomplete="off">
<div class="cmp-search__field">
<i class="cmp-search__icon" data-cmp-hook-search="icon"></i>
<span class="cmp-search__loading-indicator" data-cmp-hook-search="loadingIndicator"></span>
<input class="cmp-search__input" data-cmp-hook-search="input" type="text" name="fulltext" placeholder="${'Search' @ i18n}"
role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-invalid="false">
<button class="cmp-search__clear" data-cmp-hook-search="clear">
<i class="cmp-search__clear-icon"></i>
</button>
</div>
</form>

I'm attaching the OOTB servlet code as well and that'd help in case you'd like to go for custom approach.
https://drive.google.com/file/d/1VfbGSSPt-xqO3W83URxYju2-GvqwgK37/view?usp=sharing

Answers (1)

Answers (1)

jetate

24-06-2020

By default, the cqPageLucene oak:index only indexes 4 nodes deep (*/*/*/*). 

 

To increase the node depth for search, you can add additional includes under oak:index/cqPageLucene/aggregates/cq:PageContent with additional levels. By adding include4 (*/*/*/*/*) and include 5 (*/*/*/*/*/*) to my aggregates, my nested components began producing search results.

 

lucene.PNG