0

I am seeing the follwoing error in system.log files.

[2022-08-20 05:33:36] main.ERROR: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [number_of_bowls] in order to load field data by uninverting the inverted index. Note that this can use significant memory."}]

This is one of the attributes that is giving the error: number_of_bowls

I researched on this error and found out that this attribute should not have backend type text saved in the database. Reason why this would have happened is explained in the follwoing github issue.

https://github.com/magento/data-migration-tool/issues/646

Short explaination from above link why this would have happened:

In Magento 1 multiple select attributes are created with backend type text.
In Magento 2 multiple select attributes are created with backend type varchar.

Migrated multiple select attributes are migrated to Magento 2 with backend type text.
The migrated attribute data is therefore in a different table, catalog_product_entity_text
rather than catalog_product_entity_varchar.

So this issue occurs during migrating from M1 to M2.

But now my question is that my attribute does not have any problems as listed above. It has all the data in the proper tables and also the backend type is set to int and also it is not a multiple select attribute but a select attribute.

But still I am getting this issue for the above attribute. Could any one suggest why it is happening if everything is fine in my attribute's case.

Screenshot of the attributes's data just to be sure that it has everything as expected in the database.

Screenshot from eav_attribute table

enter image description here

Also its data is saved in catalog_product_entity_int table

enter image description here

And the value for this attributes in eav_attribute_option_value table enter image description here

So now you guys can see that this attribute does not have any wrong settings but still it is giving me this error. Could someone guide me why this could be happening as I could not find anything regarding this.

Edit: Edits according to Jitendra Patel answer I have updated the value in source_column field and still I got the error in the logs.

Screenshot of error from the logs. enter image description here

Screenshot of the source_model field from the database enter image description here

Also I have checked that this attribute's data for products is saved in catalog_product_entity_int table. enter image description here

Please have a look and guide what could be happening as I am really stuck in solving this issue.

Edit2: I was not able to find the error string in the code. But I found the error string key, so I think this is the function where the error is generated.

File Path:

vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php

Code:

private function tryDeserializeError(array $response, string $errorClass): ElasticsearchException
{
    $error = $this->serializer->deserialize($response['body'], $response['transfer_stats']);
    if (is_array($error) === true) {
        if (isset($error['error']) === false) {
            // <2.0 "i just blew up" nonstructured exception
            // $error is an array but we don't know the format, reuse the response body instead
            // added json_encode to convert into a string
            return new $errorClass(json_encode($response['body']), (int) $response['status']);
        }
        
        // 2.0 structured exceptions
        if (is_array($error['error']) && array_key_exists('reason', $error['error']) === true) {
            // Try to use root cause first (only grabs the first root cause)
            $root = $error['error']['root_cause'];
            if (isset($root) && isset($root[0])) {
                $cause = $root[0]['reason'];
                $type = $root[0]['type'];
            } else {
                $cause = $error['error']['reason'];
                $type = $error['error']['type'];
            }
            // added json_encode to convert into a string
            $original = new $errorClass(json_encode($response['body']), $response['status']);

            return new $errorClass("$type: $cause", (int) $response['status'], $original);
        }
        // <2.0 semi-structured exceptions
        // added json_encode to convert into a string
        $original = new $errorClass(json_encode($response['body']), $response['status']);
        
        $errorEncoded = $error['error'];
        if (is_array($errorEncoded)) {
            $errorEncoded = json_encode($errorEncoded);
        }
        return new $errorClass($errorEncoded, (int) $response['status'], $original);
    }

    // if responseBody is not string, we convert it so it can be used as Exception message
    $responseBody = $response['body'];
    if (!is_string($responseBody)) {
        $responseBody = json_encode($responseBody);
    }

    // <2.0 "i just blew up" nonstructured exception
    return new $errorClass($responseBody);
}
2
  • Can you share the code that occurs this error?
    – Aaron Wang
    Commented Aug 30, 2022 at 13:44
  • I have updated my question according to your comment, please have a look. Commented Aug 31, 2022 at 6:37

1 Answer 1

0

In one of the projects, I was facing this type of issue.

You are using this Attribute(number_of_bowls) on the Product Listing page as a filter option?

If "No" then go to Admin->Stores->Product & Select the attribute(number_of_bowls) from the product attribute list & check the below setting & change the "Use in Layered Navigation" option to "NO" & do the Reindexing.

enter image description here

Run the below Reindex Commands after changing the above setting.

php bin/magento indexer:reindex

Please check the source model column value showing null in the eav_attribute table. According to me, it should have a below value.

Magento\Eav\Model\Entity\Attribute\Source\Table
8
  • We can use int attributes in layered navigation. Nothing is wrong with my attribute. I have explained it in the question that I am getting this error even when my attribute is of int type. Please read the question and let me know If I was not clear in my question regarding this then I will update it. Commented Aug 25, 2022 at 6:05
  • I have updated my answer pls check now. Commented Aug 25, 2022 at 14:07
  • As per your shared screenshot of the eav attribute table, the Source Model Column value is NULL for this reason Magento considers this attribute(number_of_bowls) as Text instead of INT. Commented Aug 26, 2022 at 13:02
  • ok, I am trying this solution Commented Aug 26, 2022 at 13:45
  • 1
    I also checked the value for this attribute for the products and found out that data is in proper tables, ie in catalog_product_entity_int table. I am not sure what I am missing here. Could it be elastcisearch configuration issue on server. Commented Aug 30, 2022 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.