Magento 2 Enterprise: Elasticsearch Indexing Issue
-
12-12-2020 - |
Question
I have configured elasticsearch properly. I have tested the connection which result me success message.
The issue I am facing is I am not able to see products in my catalog category frontend. When I tried to look into the index created in elasticsearch I found it blank.
When I reindex I get this error
Design Config Grid index has been rebuilt successfully in 00:00:06
Customer Grid index has been rebuilt successfully in 00:00:00
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:00
Stock index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Catalog Search indexer process unknown error:
illegal_argument_exception: Illegal dynamic template parameter: [match_mapping]
Product/Target Rule index has been rebuilt successfully in 00:00:00
Target Rule/Product index has been rebuilt successfully in 00:00:00
Sales Rule index has been rebuilt successfully in 00:00:00
Whats this
Catalog Search indexer process unknown error:
illegal_argument_exception: Illegal dynamic template parameter: [match_mapping]
Why am I getting this error when using with elasticsearch. Is there something I have to map?
Solution
You need to install a version 2.x of Elasticsearch, example 2.4.6
OTHER TIPS
Magento added support for Elasticsearch 5+ in 2.2.2 or 2.2.3 (before that only 2.x was supported), and to use that you need to set the Search Engine setting to Elasticsearch 5.0+ in admin, or
magento config:set catalog/search/elasticsearch5_server_hostname elasticsearch
(whereelasticsearch
your ElasticSearch server hostname)magento config:set catalog/search/engine elasticsearch5
in CLI.
You should not use latest version of elasticsearch. The idea is following: there are 3 different elasticsearches:
- elasticsearch as service (written on java)
- elasticsearch php extension (https://github.com/elastic/elasticsearch-php)
- elasticsearch magento extension (magento/module-elasticsearch)
According magento extension config it requires following version of php elasticsearch extension: "elasticsearch/elasticsearch": "~2.0"
.
When you are configuring your environment, you most likely trying to use latest version of elasticsearch java extension. For today latest version is 5.5.2, which is not compatible with php extension v.2.0.
However latest version of php extension is 5.0. Suppose that if you modify magento extension use php extension 2.0 - everything can work (if it's compatible with that version :) )
Wrong way
www-data@magento2-cron:~/magento$ curl -XGET 'elasticsearch:9200'
{
"name" : "blabla",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "blablablabla",
"version" : {
"number" : "5.5.2",
"build_hash" : "blablablabla",
"build_date" : "2017-08-14T12:33:14.154Z",
"build_snapshot" : false,
"lucene_version" : "6.6.0"
},
"tagline" : "You Know, for Search"
}
Attempt to reindex:
www-data@magento2-cron:~/magento$ php bin/magento indexer:reindex catalogsearch_fulltext
Catalog Search indexer process unknown error:
illegal_argument_exception: Illegal dynamic template parameter: [match_mapping]
Correct way
www-data@magento2-cron:~/magento$ curl -XGET 'elasticsearch:9200'
{
"name" : "blabla",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "blablablabla",
"version" : {
"number" : "2.4.6",
"build_hash" : "blablablabla",
"build_timestamp" : "2017-07-18T12:17:44Z",
"build_snapshot" : false,
"lucene_version" : "5.5.4"
},
"tagline" : "You Know, for Search"
}
Attempt to reindex:
www-data@magento2-cron:~/magento$ php bin/magento indexer:reindex catalogsearch_fulltext
Catalog Search index has been rebuilt successfully in 00:00:02