1

I installed elasticsearch and the Magento backend connection test to elasticsearch is successful. If I save settings, clear the cache and reindex as described in the Magento devdocs, all product cateogries are empty and my search function has no result, whatever I type in there. I can still access the products with the direct url, thats all. If I switch back to MYSQL as search engine and clear the cache all products are back. Both Magento and Elasticsearch are Ubuntu18.04 servers, Magento 2.3.2 and Elasticsearch 6.8.3. Any idea where I can take a deeper look or how this problem can be solved?

EDIT: Some product attributes were not enabled for search (but not all! So there must have been results before). I reindexed and now the ES shows very good results! But as before, product pages are empty.

EDIT 2: Its a Multistore. The website id 1 works with ES, all other websites have no search results – and everywhere empty categories.

  • Change one of the category layout from admin. Empty layout or no design updates may create issue – sandip Sep 28 at 12:13
  • All categories were set to use the parent category setting, and the parent category is set to 1 column layout. Changes in any way do not lead to a changed behavior of the category content – they are still empty but I can see different column layouts depending on my choice ;-) – Plastikschnitzer Sep 28 at 14:06
  • Refer elastic search logs, and Put some logs on below class. This will ensure that ES is returning some products github.com/magento/magento2/blob/2.3/app/code/Magento/… – sandip Sep 28 at 14:26
  • 1
    I saw some product attributes were not enabled for search. Now I reindexed and the search shows very good results! But still, product pages are empty. – Plastikschnitzer Sep 28 at 14:47
0

Some issues are still with sorting when an elastic search is using as a catalog search engine. To resolve it, you can apply below patch specifically to Magento 2.3.2 and Elasticsearch 6+.

Go to the below file and add a plugin on the below class.

Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplier.php

Find apply() method and replace it with the below function. This is hotfix introduced by Magento recently by adding $this->collection->setPageSize(null); to the SearchResultApplier.php class.

    public function apply()
    {
        if (empty($this->searchResult->getItems())) {
            $this->collection->getSelect()->where('NULL');
            return;
        }
        $ids = [];
        foreach ($this->searchResult->getItems() as $item) {
            $ids[] = (int)$item->getId();
        }
        $this->collection->setPageSize(null);
        $this->collection->getSelect()->where('e.entity_id IN (?)', $ids);
        $orderList = join(',', $ids);
        $this->collection->getSelect()->reset(\Magento\Framework\DB\Select::ORDER);
        $this->collection->getSelect()->order("FIELD(e.entity_id,$orderList)");
    }

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.