1

Before I enabled ElasticSearch the search bar would give me a list of categories, products, and blog posts that matched. And when I hit enter the search results page would contain the matching products.

After I enabled ElasticSearch the search term suggestions show, but the results page contains no products. Oddly if I do an "advanced search" (/catalogsearch/advanced) I do get the results I would expect.

I'm using Magento 2.3.4 with ElasticSearch 6.8.7.

I've done the following on my test server to try to diagnose the problem:

  • Configured and setup ElasticSearch.
  • Configured Magento according to the Magento documentation, I get the "Successful! Test Again?" button
  • Run bin/magento indexer:reindex
  • Installed kibana to make sure I can see and search the data in ElasticSearch, I can.
  • Switched to the luma theme to eliminate the theme as the issue.
  • Checked log files for new error message (error, exception, system). No messages were generated doing searches besides access log messages.

If anyone has any suggestions or advice I'd greatly appreciate it.

Thanks, Brian

1

After some discussion with a co-worker we disabled all modules and re-enabled them one at a time. This led us to some custom code that was designed specifically for the mysql search. The offending part of the module was in:

app/code/[company]/[module]/etc/search_request.xml

Once we removed that file, recompiled and reindex the data the search was working.

| improve this answer | |
0

Give a try below to check atleast if ElasticSearch returns some results or not?

File: Check\Es\etc\di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <type name="Magento\Elasticsearch\SearchAdapter\ResponseFactory">
      <plugin name="ESChecker::willReturnsDocuments" type="Check\Es\Plugin\ESResponseCheck" sortOrder="1" disabled="false" />
    </type>
</config>

File: Check\Es\Plugin\ESResponseCheck.php

<?php
namespace Check\Es\Plugin;

use Magento\Elasticsearch\SearchAdapter;
use Psr\Log\LoggerInterface;


class ESResponseCheck
{

    protected $logger;

    public function __construct(
        LoggerInterface $logger        
    ) {
        $this->logger = $logger;

    }

    public function beforeCreate(\Magento\Elasticsearch\SearchAdapter\ResponseFactory $subject, $result)
    {
       if(!is_array($result) || empty($result)) return false;
       foreach ($result['documents'] as $rawDocument) {
            $this->logger->debug('ELASTIC_SEARCH_DEBUG_CODE',$rawDocument);   
       }            

    }
}

Clear the cache and catalog search reindexing

Perform any search terms and check var/debug.log file found in the Magento root directory.

In the debug.log file look for the product IDs returns from the ElasticSearch.

Also, check below URL for further info - https://magento.stackexchange.com/a/285358/34579

| improve this answer | |
  • Thanks for the suggestion, we verified that we were getting results from ElasticSearch. – Brian Milco Apr 6 at 23:21
  • Glad to see that. – sandip Apr 7 at 2:11

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.