Broadleaf Microservices
  • v1.0.0-latest-prod

Customizing Search and Indexing

Introduction

Extension patterns for search and indexing capabilities are slightly different than other Broadleaf services.

Because of this, Broadleaf’s search and indexer capability were designed to be easily extended without modifying default behavior. This is achieved through a contributor pattern. Search, indexing, and type ahead all follow this pattern.

Search Request Flow

To customize the search request, implement SolrQueryContributor or use the convenience class AbstractSolrQueryContributor.

Note
When writing a custom contributor, do not use SolrQuery#setFields(String…​). This overwrites any other fields that have already been added to the query. Instead, add each individual field using SolrQuery#addField(String)

To customize the search response, implement SolrResponseDecorator.

Customizing Type Ahead

Typeahead requests follow the same contributor/decorator flow, with one exception: a SolrQueryContributor used on standard search requests may or may not be executed. This is determined by the SolrQueryContributor#contributeOnTypeAhead method. Standard response decorators are not executed on TypeAhead requests.

To customize the type ahead request, implement TypeAheadPreProcessor.

To customize the type ahead response, implement TypeAheadPostProcessor.

Customizing Indexer

Customizing the indexing flow similarly follows a contributor pattern using two different mechanisms:

  1. Items to be indexed may be pre-processed by implementing a DocumentBuilderPreProcessor if it is necessary to transform the items being indexed before entering the contributor flow.

  1. To customize the actual index behavior, implement DocumentBuilderContributor.