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

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Catalog search

Catalog search

Catalog search allows a customer using the front end or a sales representative using the Commerce Manager to find products by keywords. At configured intervals, keywords are extracted from each product in the catalog and stored in a Solr index 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 Solr 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.

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.
Note:

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

Configuration

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