diff --git a/vendor/magento/module-search/Model/ResourceModel/Query/Collection.php b/vendor/magento/module-search/Model/ResourceModel/Query/Collection.php
index e122f61ff1b29..824af43034adb 100644
--- a/vendor/magento/module-search/Model/ResourceModel/Query/Collection.php
+++ b/vendor/magento/module-search/Model/ResourceModel/Query/Collection.php
@@ -1,7 +1,7 @@
_storeManager->getStore()->getId();
$this->addStoreFilter($storeIds);
- $this->getSelect()->where('num_results > 0');
+ $this->getSelect()->where('main_table.num_results > 0');
- $this->getSelect()->order(['popularity desc']);
+ $this->getSelect()->order(['main_table.popularity desc']);
return $this;
}
@@ -171,11 +171,10 @@ public function isTopSearchResult(string $term, int $storeId, int $maxCountCache
$select = $this->getSelect();
$select->reset(\Magento\Framework\DB\Select::FROM);
$select->reset(\Magento\Framework\DB\Select::COLUMNS);
- $select->distinct(true);
$select->from(['main_table' => $this->getTable('search_query')], ['query_text']);
$select->where('main_table.store_id IN (?)', $storeId);
- $select->where('num_results > 0');
- $select->order(['popularity desc']);
+ $select->where('main_table.num_results > 0');
+ $select->order(['main_table.popularity desc']);
$select->limit($maxCountCacheableSearchTerms);
@@ -208,7 +207,7 @@ public function setRecentQueryFilter()
public function addStoreFilter($storeIds)
{
$condition = is_array($storeIds) ? 'main_table.store_id IN (?)' : 'main_table.store_id = ?';
- $this->getSelect()->where($condition, $storeIds);
+ $this->getSelect()->where($condition, $storeIds, \Zend_Db::INT_TYPE);
return $this;
}
diff --git a/vendor/magento/module-search/etc/db_schema.xml b/vendor/magento/module-search/etc/db_schema.xml
index c5ad1aae1d60e..636b3cb027cc2 100644
--- a/vendor/magento/module-search/etc/db_schema.xml
+++ b/vendor/magento/module-search/etc/db_schema.xml
@@ -1,8 +1,8 @@
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+