Setup

smartSuggest is a library built on top of Apache Lucene that provides high-quality query and product suggestion capabilities. The Java library can be integrated directly into applications to build a custom suggestion service. Alternatively, it is also available as a ready-to-use HTTP service packaged as a container image.

Requirements

  • Network Access: The application must be able to connect to https://query.searchhub.io/, which is used to fetch the SearchHub suggestion data.

  • Temporary directory access: The embedded Apache Lucene library creates several indexes in the system’s temporary directory. Ensure the application has permission to write to the OS temp directory. The indexed data is volatile and does not require permanent persistence. When running inside the container image, this should work without additional configuration.

  • Memory requirements: The service is designed to minimize memory usage. In typical setups, it requires approximately 100 MB to 500 MB of Java heap memory. The exact memory requirement may increase depending on the volume of data managed by the service.

  • Java Version: For Java integration, JDK 17 or newer is required.

Installation

Our continuous integration pipeline publishes the library to our internal Maven repository and subsequently builds the corresponding Docker image.

The docker image is available on docker hub with the name commerceexperts/searchhub-smartsuggest-service

docker run -d --name=smartsuggest-service -e SH_API_KEY=<YourS3cr3tAPIkey> -P commerceexperts/searchhub-smartsuggest-service:2.5.5

The container must be initiated with your API key set to the environment variable SH_API_KEY. The container exposes port 8081 which can be mapped to any port.

Client Setup

For a pure Suggest integration, we recommend to use endpoint v3. But there are more different ones that might fit better to your needs. Continue reading the Service Integration for all according details.

$> port=38081
$> tenant_name="example"
$> tenant_channel="com"
$> curl -s "http://localhost:$port/smartsuggest/v3/$tenant_name/$tenant_channel?userQuery=jea" -o - | jq .

Troubleshooting

  • Missing API Key: If no API key is specified, the container will terminate with the following log message: “IllegalArgumentException: no searchHub API key provided! Either specify ENV var ‘SH_API_KEY’ or system property ‘searchhub.apikey’”

  • If the service attempts to access a tenant or channel that is not permitted (for example, due to an incorrect API key), the following message may appear in the logs: Unauthorized while fetching data for tenant ‘foo.bar’: [401 Unauthorized]

  • Enabling Debug Logging: To obtain more detailed information about internal processes, enable debug logging. When running the container, use the following Docker startup parameter: -e JAVA_TOOL_OPTIONS="-Dlog.searchhub.level=DEBUG" For even more verbose logging, you can also enable root-level debug logging -Dlog.root.level=DEBUG.