Get more content like this

Customizing the order of search results

Customizing the Order of Search Results

Suppose you have a group of nodes/pages on your site for e.g. FAQs, Case Studies  and you want to provide  a feature so that visitors can search on that content.  You also want to give higher weightage to some properties/field values of the node/page.  For e.g. if the search term occurs in the title then show that result first.

The following are the configuration steps to achieve this.

1. Update \crx-quickstart\repository\workspaces\crx.default\workspace.xml and add the line below (bolded)


<SearchIndex class=""> <param name="path" value="${wsp.home}/index"/> <param name="resultFetchSize" value="50"/> <param name="indexingConfiguration" value="${wsp.home}/indexing_config.xml"/> </SearchIndex>

2. Create the file /crx-quickstart/repository/workspaces/crx.default/indexing_config.xml and copy the content from this link

3. Include the following lines in the above the file. Change the condition and properties as per your need.

<index-rule nodeType="nt:unstructured" condition="@sling:resourceType = 'app1/components/faq'"> <property boost="3.0">question</property> <property >answer</property> <property >sling:resourceType</property> </index-rule>

4. Re-index the repository. 

Delete the following in the directory /crx-quickstart/repository/workspaces/crx.default/



5. Now write your query and use fulltext search on the relevant properties that you are searching.

Sample Query:

path=/content/xxx/FAQs/jcr:content/ type=nt:unstructured 1_property=sling:resourceType 1_property.value=app1/components/faq group.p.or=true group.1_fulltext=My_Search_String group.1_fulltext.relPath=@question group.2_fulltext= My_Search_String group.2_fulltext.relPath=@answer


How to debug JCR Queries

How to use 'Boosts' at Indexing Time and at Query Runtime

Indexing Configuration

If you would like more help optimizing or managing your AEM Contact Us Today.

Learn more about how TechAspect can help you propel your digital transformation

Get In Touch