Search code examples
broadleaf-commerce

Add search suggestion in both API and site on broadleaf community edition


How to add search suggestion in site and API similar to broadleaf demo site?

I can't find search suggestion in my broadleaf spring-boot community edition.


Solution

  • You can achieve this by adding list of keywords for every product.

    In schema.xml
    1. Add a new field keyword for storing keywords from db
    2. Add copyfield suggest_phrase for suggestion
    3. copy keyword, manufacture field in suggest_phrase.

    In solrconfig.xml,
    1. Create searchcomponent in the name of "suggest"
    2. Create request handler "/suggest" for that component which should have field as suggest_phrase.

    Extend SolrSearchIndexImpl.java to add keywords in solr while reindexing.
    You will get keywords as suggestion.