0

I'm using Magento 2.3 with ElasticSearch 6, I have 20k different searches per day.

I can see the top search terms in my Dashboard, but when I access the page Marketing > SEO & Search > Search Terms I'm redirected to the login page.

Stack trace

…lled at /app/mdhksik627pps/vendor/magento/framework/Session/
SessionManager.php (150)
in Magento\Framework\Session\SessionManager::writeClose called at ? (?)

MySQL Query

Magento 2 New relic MySQL Search Terms

How could I solve it?

0

The issue is the amount of data processed, you can improve the queries limits to return just the top results or you can apply these changed below via path or module to eliminate the counting of search terms.

Index: vendor/magento/module-search/Model/Query.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- a/vendor/magento/module-search/Model/Query.php  (date 1589899020381)
+++ b/vendor/magento/module-search/Model/Query.php  (date 1589899020381)
@@ -243,7 +243,8 @@
      */
     public function saveIncrementalPopularity()
     {
-        $this->getResource()->saveIncrementalPopularity($this);
+        // Removed to save MySQL resources
+        // $this->getResource()->saveIncrementalPopularity($this);

         return $this;
     }
@@ -259,7 +260,9 @@
     public function saveNumResults($numResults)
     {
         $this->setNumResults($numResults);
-        $this->getResource()->saveNumResults($this);
+
+        // Removed to save MySQL resources
+        // $this->getResource()->saveNumResults($this);

         return $this;
     }

Index: vendor/magento/module-search/Model/PopularSearchTerms.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- a/vendor/magento/module-search/Model/PopularSearchTerms.php (date 1589899721241)
+++ b/vendor/magento/module-search/Model/PopularSearchTerms.php (date 1589899721241)
@@ -48,13 +48,9 @@
      */
     public function isCacheable(string $term, int $storeId)
     {
-        $terms = $this->queryCollection
-            ->setPopularQueryFilter($storeId)
-            ->setPageSize($this->getMaxCountCacheableSearchTerms($storeId))
-            ->load()
-            ->getColumnValues('query_text');
-
-        return in_array($term, $terms);
+        // Removed cacheable checks to save MySQL resources as there can be
+        // around 20k different terms used per day
+        return false;
     }

     /**
| improve this answer | |

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.