I am getting the error for the below code.

public function apply(\Magento\Framework\App\RequestInterface $request)
        $filter = $request->getParam($this->_requestVar);
        if (!$filter || is_array($filter) ) {
            return $this;

        $this->appliedFilter = $filter;
        $filters = explode(',', $filter);

        if (!$this->filterPlus) {
            $this->filterPlus = true;

        $attribute = $this->getAttributeModel();
        $productCollection = $this->getLayer()->getProductCollection();
        // apply filtter to collection
        $productCollection->addFieldToFilter($attribute->getAttributeCode(), ["finset" => $filters]);

        foreach ($filters as $option) {
            $text = $this->getOptionText($option);
            if ($option && strlen($text)) {
                    $this->_createItem($text, $option)

        return $this;

The error is,

main.CRITICAL: {"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:263] [terms_lookup] unknown field [finset]"}],"type":"x_content_parse_exception","reason":"[1:272] [bool] failed to parse field [must]","caused_by":{"type":"x_content_parse_exception","reason":"[1:263] [terms_lookup] unknown field [finset]"}},"status":400} {"exception":"[object] (Elasticsearch\Common\Exceptions\BadRequest400Exception(code: 400): {"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:263] [terms_lookup] unknown field [finset]"}],"type":"x_content_parse_exception","reason":"[1:272] [bool] failed to parse field [must]","caused_by":{"type":"x_content_parse_exception","reason":"[1:263] [terms_lookup] unknown field [finset]"}},"status":400} at /opt/magento/public_html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:632)"} []

This usually happens with multi values filter. For example,


The Elasticsearch version is 7.13.2 and Magento version is 2.4.2

  • May you please explain more How "finset" is related with this code, may you try to back track or back trace to see whats colums present in your database table. In your product and attribute table. Jul 8 at 14:49

Change the following line from

$productCollection->addFieldToFilter($attribute->getAttributeCode(), ["finset" => $filters]);


$productCollection->addFieldToFilter($attribute->getAttributeCode(), $filters);

Guys the solution is simple, check your website access log.

There are some search engine bots accessing your website for crawling, some are going in depth doing filter products list. This cause error, as bot trying to play with our filter/search system.

(bot like semrush, etc)

This is the reason for exception error log from elasticsearch.

To prevent this, make sure setup proper robots.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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