Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. The Developer Center continues to support Commerce 6.13.0 through 7.4.1.Visit new site

Catalog search

Catalog search

Catalog search allows a customer in the storefront or a sales representative in the Commerce Manager find products by specifying keywords. At configured intervals, keywords are extracted from each product in the catalog and stored in a Lucene index to allow for fast searching.

Key classes and files

In Core:

  • SearchRequestImpl - A search request representation.
  • SearchResultImpl - A search result representation.
  • SearchServiceImpl - A service for searching the product catalog.
  • ProductCategorySearchCriteria - A product search criteria representation.
  • ProductQueryComposerImpl - A Lucene query composer for products.
  • SolrIndexSearchServiceImpl - A service for dispatching search requests to the SolrIndexSearcher.
  • SolrIndexSearchResultImpl - A Solr result representation.
  • SolrIndexSearcherImpl - A searcher that can read Lucene-based indexes.

In Storefront:

  • SearchControllerImpl - Assembles a SearchRequest object from the user's search parameters, and retrieves a SearchResult object by executing a search with a SearchService.

How it works

  1. A user inputs a string of keywords, and possibly a category restriction, into the search fields and clicks search. This invokes SearchControllerImpl's handleRequestInternal() method.
  2. SearchControllerImpl creates a SearchRequest object.
  3. SearchControllerImpl calls the SearchService with the following input:
    1. The SearchRequest.
    2. The user's ShoppingCart, which is used to apply promotion rules.
    3. The ProductLoadTuner, which determines how much of a product's data is loaded.
  4. SearchService checks the COMMERCE/STORE/SEARCH/searchCategoriesFirst system setting whether it should search for categories before products. If SearchService finds a category, the search stops and returns the category page.
  5. If no categories are found, SearchService creates a ProductCategorySearchCriteria from the SearchRequest.
  6. SearchService dispatches the ProductCategorySearchCriteria to the injected SolrIndexSearchService, which returns an empty SolrIndexSearchResult that has been injected with a SolrIndexSearcher.
  7. SearchService applies pagination to the SolrIndexSearchResult and delegates to the SolrIndexSearcher.
  8. SolrIndexSearcher converts the ProductCategorySearchCriteria into a ProductQueryComposer.
  9. SolrIndexSearcher uses the ProductQueryComposer to generate a Solr query and runs a search.
  10. If no results are found, SolrIndexSearcher uses the ProductQueryComposer to generate a Fuzzy query and runs a Fuzzy search.
  11. SearchService regains control with the populated SolrIndexSearchResult.
  12. If not enough results are returned, SearchService attempts to generate suggestions, as described by Search Suggestions.
  13. SearchService returns the results to the SearchController along with any suggestions.

By default, the data included in each object in the result set is determined by the productLoadTunerForBrowsingAndSearch. For more information, see Load tuners.


To configure Fuzzy Search and Search Suggestions, see the Search Settings page.