How to use the Enhanced Autocomplete for Elasticsearch 6/7 extension?
Elasticsearch is a real-time distributed search and analytics engine that allows you to explore your data very quickly. It is used for full-text search, structured search, analytics, and all three in combination.
And it packages up all these functionalities into a standalone server that your application can talk to via a simple RESTful API, using a web client from your favorite programming language, or even from the command line.
The Enhanced Autocomplete extension will allow you to make the link between the search and analytics engine and Magento.
The extension is completely compatible with Elasticsearch server v6 and v7.
You can find more information on the product here:
STEP 1: Install and run Elasticsearch server
As Elastic advises, "the easiest way to understand what Elasticsearch can do for you is to play with it".
To be able to use the Enhanced Autocomplete extension and reach the server, you first need to have a recent version of Java. You can easily install the latest version of Java from www.java.com .
Then you can install and run the Elasticsearch engine following the below steps.
Install Elasticsearch
You can download the latest version of Elasticsearch compatible with our extension from elastic.co/downloads/elasticsearch.
Once it is downloaded, you can extract the archive file.
Run Elasticsearch
To run Elasticsearch, open a console, and run the following command:
cd elasticsearch-<version>./bin/elasticsearch
If you’re running Elasticsearch on Windows, simply run:
bin\elasticsearch.bat
Test Elasticsearch
You can easily test if the Elasticsearch engine is reached by opening a new terminal window and running the following:
curl 'http://localhost:9200/?pretty'
You should then get:
You now have an Elasticsearch node up and running.
STEP 2: Enable the Elasticsearch method
To configure Enhanced Autocomplete for Elasticsearch 6/7 in a general way, go to:
SystemConfigurationCatalog Catalog Search
Configure the general parameters
In the Catalog Search tab, you can choose Elasticsearch as the Search Engine.
When choosing Elasticsearch as the Search engine, more options should display:
- Enable Debug Mode
Will display potential error messages in the frontend. - Enable Suggestion
Will display a suggestion if the search engine detects a better text query ("Do you mean?" feature).
- Servers
Must be written as host:port and separated by a comma.
To check the connection, click on Check Servers. - Verify Host
Only used for HTTPS connection. Set that option to No if you don't have a valid SSL certificate. - Server Timeout
Number of seconds after a timeout occurs for every request. If you’re using indexing of file, a large value is necessary. - Index Prefix
Used to prefix index names in order to avoid potential collisions. - Number of Shards
Having more shards enhances the indexing performance and allows to distribute a big index across machines. - Number of Replicas
Define the number of replicas. Note that having more replicas enhances search performance and improves cluster availability. - Safe Reindex
Reindex in a temporary index and switch to it once finished. Especially useful for large product catalogs.
- Query Operator
By default, it is set to AND. For example, with the AND operator, the same query is translated to "digital AND camera", with the OR operator, the query "digital camera" is translated to "digital OR camera". You may have fewer results with the AND operator but they’ll be more relevant. - Enable Source Storage
Should we store source data in Elasticsearch or not. Keep this setting to No for better performances. Will be forced to Yes if fast autocomplete is enabled. - Enable Fuzzy Query
Enable the approximate search. - Fuzzy Query Mode
You have the possibility to choose the fuzziness level. For example:
0, 1, 2: the maximum allowed Levenshtein Edit Distance (or number of edits)
AUTO: should generally be the preferred value. Generates an edit distance based on the length of the term.
For lengths:
0..2: must match exactly
3..5: one edit allowed
>5: two edits allowed
- Display in stock product first
When this option is enabled, the out of stock products will be displayed after the in-stock products. - Analyze SKUs
When Fuzzy Query is enabled, you have the possibility to analyze the SKUs. The SKUs will be analyzed like other product attributes. It is useful if SKUs are multi-part values, such as XXX-YYY-ZZZ. If you don't want to analyze SKUs, then the SKU attribute is considered as one single word.
Manage your Indexes
The Enhanced Autocomplete extension adds 3 more indexes that you can find in:
SystemIndex Management
- Elasticsearch Product
Rebuild product full-text search index - Elasticsearch Category
Rebuild category full-text search index - Elasticsearch CMS Pages
Rebuild CMS pages full-text search index
You can easily reindex data by selecting those 3 indexes and by clicking on Submit .
STEP 3: Configure your search with Elastic Search
You can now configure your search in:
SystemConfigurationWYOMIND Elasticsearch
General Settings
In the General Settings subtab, you will be able to Enable Response Header. This will enable a custom response header for debug purposes.
Autocomplete Settings
By default, the autocomplete will display terms suggestions for your search.
You can choose to Enable Autocomplete in order to override the default autocomplete and to display products directly.
If enabled, 3 additional options will be displayed:
- Enable Fast Autocomplete
Use the fast autocomplete (with a payload during indexation). - Autocomplete labels
You can also define a translation for each one of the labels that will be displayed in the autocomplete box as well as add new ones in the Autocomplete Labels field.
That option is very useful if your website is available in different languages. You can then change the scope to a store view, for example, the French one, and translate each autocomplete label to the French word. - Enable Autocomplete Suggestions
You can enable the suggestions in the autocomplete (do you mean?). - Suggestions limit
You can define the maximum number of suggestions to display.
Below is what you should get with the above example:
Product Settings
With the Enhanced Autocomplete extension, you can make your products searchable in the autocomplete box. Several options exist to enhance the search.
- Enable Auto Redirect
If only 1 result matches the query, the user will be redirected to the product page automatically. - Enable in Autocomplete
If enabled, products will be searchable in the autocomplete box. - Autocomplete Limit
Define the maximum number of results displayed in the autocompletion. For example 3. - Display image
To display product image in the autocomplete.
- Image Size
Define the size of the images in the autocomplete box in px. By default, the value is set on 50 px. - Enable Thumbnails Generation
Enable that option if you want to generate product thumbnails. They’ll be generated during indexation and increase execution time. Note that this will impact only the first indexation process since thumbnails are cached for the next indexations. If that option is disabled, the uploaded images will be used without any payload at indexation time but big images may be loaded in autocomplete box. - Index product custom options
Product custom options will be indexed and searchable. This requires a new indexation.
Category Settings
You can Enable Category Search. If enabled, categories will then be indexed in Elasticsearch and new parameters will be displayed in the configuration.
- Enable in Search Results
If enabled, categories will also be displayed in the right column of the search results page. - Enable in Autocomplete
If enabled, categories will also be searchable in autocomplete box. - Autocomplete Limit
Define the maximum number of results displayed in the autocompletion. For example 2.
- Search Results Limit
Is the limit number of results that will be displayed in the right column of the search results page. Note that 0 or empty field means unlimited. - Show Category Path
If enabled, the category path will be displayed in the right column of the search results page. - Searchable Attributes
Define which category attributes are searchable. For example the Description and the Name. - Index Categories not included in the menu
You also have the possibility to index categories that are not in the menu.
CMS Settings
You can Enable CMS Search. If enabled, CMS pages will be indexed in Elasticsearch and new parameters will be displayed in the configuration.
- Enable in Search Results
If enabled, CMS pages will also be displayed in the right column of the search results page.
- Enable in Autocomplete
If enabled, CMS pages will also be searchable in the autocomplete box. - Autocomplete Limit
Define the maximum number of results displayed in the autocompletion. For example 3.
- Search Results Limit
Limit the number of results displayed in the right column of the search results page. Note that “0” or empty means unlimited. - Searchable Attributes
Define which attributes are searchable. - Excluded Pages
Selected CMS pages will be excluded from the search.
STEP 4: Manage the weight of the attributes and products in order to refine the search results
The Enhanced Autocomplete extension allows you to easily boost your product attributes and products in the search results by giving them a weight.
By product attribute
To define some weight for each one of your attributes, you can go to:
CatalogAttributes Manage ATTRIBUTES
Edit the attribute you want. In the Properties tab and Elasticsearch Settings subtab, you’ll be able to define a value from 1 to 10 depending on the weight you want to assign to it.