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.
How it works
- 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.
- SearchControllerImpl creates a SearchRequest object.
- SearchControllerImpl calls the SearchService with the following input:
-
- The SearchRequest.
- The user's ShoppingCart, which is used to apply promotion rules.
- The ProductLoadTuner, which determines how much of a product's data is loaded.
- 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.
- If no categories are found, SearchService creates a ProductCategorySearchCriteria from the SearchRequest.
- SearchService dispatches the ProductCategorySearchCriteria to the injected SolrIndexSearchService, which returns an empty SolrIndexSearchResult that has been injected with a SolrIndexSearcher.
- SearchService applies pagination to the SolrIndexSearchResult and delegates to the SolrIndexSearcher.
- SolrIndexSearcher converts the ProductCategorySearchCriteria into a ProductQueryComposer.
- SolrIndexSearcher uses the ProductQueryComposer to generate a Solr query and runs a search.
- If no results are found, SolrIndexSearcher uses the ProductQueryComposer to generate a Fuzzy query and runs a Fuzzy search.
- SearchService regains control with the populated SolrIndexSearchResult.
- If not enough results are returned, SearchService attempts to generate suggestions, as described by Search Suggestions.
- 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.