Overview
The Autocomplete module provides methods to retrieve autocomplete results from the Constructor.io API. It enables you to display search suggestions, product recommendations, and other content as users type in a search box.Key Features
- Real-time suggestions: Get autocomplete results as users type
- Sectioned results: Organize results by type (Products, Search Suggestions, etc.)
- Flexible filtering: Apply filters globally or per section
- Format control: Customize response format with hidden fields and variations mapping
- Result customization: Control the number of results per section
Methods
Get Autocomplete Results
Retrieve autocomplete results based on a search query
Common Use Cases
Basic Autocomplete
Retrieve autocomplete results for a simple search query:Results Per Section
Control the number of results returned for each section:With Filters
Apply filters to refine autocomplete results:Response Structure
All autocomplete methods return a Promise that resolves to anAutocompleteResponse object:
An object containing arrays of items organized by section name (e.g., “Products”, “Search Suggestions”)
A unique identifier for this set of results, used for tracking and analytics
The total number of results available for each section
Information about the request that generated these results
Event Tracking
The Autocomplete module automatically dispatches events that can be tracked:autocomplete.getAutocompleteResults.completed- Fired when autocomplete results are successfully retrieved