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 @@
 <?php
 /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
+ * Copyright 2011 Adobe
+ * All Rights Reserved.
  */
 namespace Magento\Search\Model\ResourceModel\Query;

@@ -150,9 +150,9 @@ public function setPopularQueryFilter($storeIds = null)

         $storeIds = $storeIds ?: $this->_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 @@
 <?xml version="1.0"?>
 <!--
 /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
+ * Copyright 2018 Adobe
+ * All Rights Reserved.
  */
 -->
 <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -35,21 +35,32 @@
             <column name="query_text"/>
             <column name="store_id"/>
         </constraint>
-        <index referenceId="SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY" indexType="btree">
+        <index referenceId="SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY" indexType="btree" disabled="true">
             <column name="query_text"/>
             <column name="store_id"/>
             <column name="popularity"/>
         </index>
-        <index referenceId="SEARCH_QUERY_STORE_ID" indexType="btree">
-            <column name="store_id"/>
-        </index>
         <index referenceId="SEARCH_QUERY_IS_PROCESSED" indexType="btree">
             <column name="is_processed"/>
         </index>
-        <index referenceId="SEARCH_QUERY_STORE_ID_POPULARITY" indexType="btree">
+        <index referenceId="SEARCH_QUERY_STORE_ID_NUM_RESULTS_POPULARITY" indexType="btree">
+            <column name="store_id"/>
+            <column name="num_results"/>
+            <column name="popularity"/>
+        </index>
+        <index referenceId="SEARCH_QUERY_QUERY_TEXT_STORE_ID_NUM_RESULTS_POPULARITY" indexType="btree">
+            <column name="query_text"/>
             <column name="store_id"/>
+            <column name="num_results"/>
             <column name="popularity"/>
         </index>
+        <index referenceId="SEARCH_QUERY_STORE_ID_POPULARITY" indexType="btree" disabled="true">
+            <column name="store_id"/>
+            <column name="popularity"/>
+        </index>
+        <index referenceId="SEARCH_QUERY_STORE_ID" indexType="btree" disabled="true">
+            <column name="store_id"/>
+        </index>
     </table>
     <table name="search_synonyms" resource="default" engine="innodb" comment="table storing various synonyms groups">
         <column xsi:type="bigint" name="group_id" unsigned="true" nullable="false" identity="true"
diff --git a/vendor/magento/module-search/etc/db_schema_whitelist.json b/vendor/magento/module-search/etc/db_schema_whitelist.json
index 16bbd0ce9fa3c..866aa43eedf0d 100644
--- a/vendor/magento/module-search/etc/db_schema_whitelist.json
+++ b/vendor/magento/module-search/etc/db_schema_whitelist.json
@@ -14,11 +14,13 @@
             "updated_at": true
         },
         "index": {
-            "SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": true,
-            "SEARCH_QUERY_STORE_ID": true,
+            "SEARCH_QUERY_QUERY_TEXT_STORE_ID_NUM_RESULTS_POPULARITY": true,
             "SEARCH_QUERY_IS_PROCESSED": true,
             "SEARCH_QUERY_SYNONYM_FOR": true,
-            "SEARCH_QUERY_STORE_ID_POPULARITY": true
+            "SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": false,
+            "SEARCH_QUERY_STORE_ID_NUM_RESULTS_POPULARITY": true,
+            "SEARCH_QUERY_STORE_ID": false,
+            "SEARCH_QUERY_STORE_ID_POPULARITY": false
         },
         "constraint": {
             "PRIMARY": true,
