Magento2: ElasticSearch MG 234

Created on 29 Feb 2020  路  10Comments  路  Source: magento/magento2

Hello,

We do experimenting an issue with Elasticsearch 6, we do not have any issues with mysql but enabling Elasticsearch in a clean installation (MG234, Ubuntu 18, Php 7.2 and 7.3 we are facing the following message.

Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider::getByAttributeCode() must be of the type string, null given, called in /var/www/html/magento2/vendor/magento/module-elasticsearch/SearchAdapter/Query/Builder/Sort.php on line 92 and defined in /var/www/html/magento2/vendor/magento/module-elasticsearch/Model/Adapter/FieldMapper/Product/AttributeProvider.php:72 Stack trace: #0 /var/www/html/magento2/vendor/magento/module-elasticsearch/SearchAdapter/Query/Builder/Sort.php(92): Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider->getByAttributeCode(NULL) #1 /var/www/html/magento2/vendor/magento/module-elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php(91): Magento\Elasticsearch\SearchAdapter\Query\Builder\Sort->getSort(Object(Magento\Framework\Search\Request)) #2 /var/www/html/magento2/vendor/magento/module-elasticsearch/Elasticsearch5/SearchAdapter/Mapper.php(66): Magento\Elasticsearch\Elasticsearch5\SearchAdapter\Qu in /var/www/html/magento2/vendor/magento/module-elasticsearch/Model/Adapter/FieldMapper/Product/AttributeProvider.php on line 72

Since there are no other mention. we assume that the problem is with any misconfiguration or typo , such as dob (by the way, it was'nt fixes In 2.3.4) in customers

Thank you in advance.

Preconditions (*)


1.
2.

Steps to reproduce (*)


1.
2.

Expected result (*)

  1. [Screenshots, logs or description]
    2.

Actual result (*)

  1. [Screenshots, logs or description]
    2.
ready for confirmation Reported on 2.3.4

Most helpful comment

Here's a simple patch I used to help fix this issue on Magento 2.3.4:

diff --git a/vendor/magento/module-elasticsearch/SearchAdapter/Query/Builder/Sort.php b/vendor/magento/module-elasticsea
index e8085787..d7fb9e7e 100644
--- a/vendor/magento/module-elasticsearch/SearchAdapter/Query/Builder/Sort.php
+++ b/vendor/magento/module-elasticsearch/SearchAdapter/Query/Builder/Sort.php
@@ -21,6 +21,7 @@ class Sort
      * List of fields that need to skipp by default.
      */
     private const DEFAULT_SKIPPED_FIELDS = [
+        null,
         'entity_id',
     ];

Update: I've noticed that sorting does not always work properly when conducting a search. This patch fixes the error message, but the underlying issue still remains.

All 10 comments

Hi @dtavieres. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@dtavieres do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hello, We did not try to reproduce the issue at vanilla Magento instance but we tried several times, with clean instances, alway we do have the same overcame. Ubuntu 18, MySql 5.6, Php 7.3 and php 7.2, mod apache and fpm, AWS ElasticSearch service 6.7 and 6.8 but always we had the same result. Since the catalog search in MYSQL mode presents no problems, something In the module elasticsearch/elasticsearch may be wrong or any kind of typo is present.
Thank you in advance.

We are facing same error with Magento CE 234

馃憟 Same exact issue
Magento 2.3.4
PHP 7.2.24
elasticsearch 6.5
mysql 10.0
hosted on Adobe Magento Cloud

Exact same issue with exact same error code on cloud:

php 7.3.11
mgc 2.3.4
elasticsearch 6.7.2
mariaDB 10.0.37

No problem on local cloud instance clone.
Local cloud clone update to 2.3.4 (no error)

php 7.1.33
mgc 2.3.4
elasticsearch 6.7.2
mysql 5.7.26

Good afternoon, Did anyone find a fix for this issue? Thank you

Here's a simple patch I used to help fix this issue on Magento 2.3.4:

diff --git a/vendor/magento/module-elasticsearch/SearchAdapter/Query/Builder/Sort.php b/vendor/magento/module-elasticsea
index e8085787..d7fb9e7e 100644
--- a/vendor/magento/module-elasticsearch/SearchAdapter/Query/Builder/Sort.php
+++ b/vendor/magento/module-elasticsearch/SearchAdapter/Query/Builder/Sort.php
@@ -21,6 +21,7 @@ class Sort
      * List of fields that need to skipp by default.
      */
     private const DEFAULT_SKIPPED_FIELDS = [
+        null,
         'entity_id',
     ];

Update: I've noticed that sorting does not always work properly when conducting a search. This patch fixes the error message, but the underlying issue still remains.

same error still appears in 2.3.5 magento/magento-cloud-metapackage. Above patch fixes it

still applies in 2.3.6

Here's I used to fix this issue on Magento 2.4.0:

etc/di.xml

<type name="Magento\Elasticsearch\SearchAdapter\Query\Builder\Sort">
    <arguments>
        <argument name="skippedFields" xsi:type="array">
            <item name="null" xsi:type="string"></item>
        </argument>
    </arguments>
</type>
Was this page helpful?
0 / 5 - 0 ratings