What is the use of search_query table in magento 2?

In Magento 2 search_query database table store the search query, which users have searched using the search box in Magento 2.
— query_text field in a search_query table in stores the value of search string. When User search through site, all of the search entry will be added to search_query table in query_text field.
num_results field used for Number of results for specific word in the site. That field show count of any string search in site.
— popularity field is displayed popularity of specific word in your site, the Biggest number will have the most popular search word for your site.
store_id will show search from a specific store.
There are some other field also available in search_query table but above field is the main field of a table.

You can check from the admin panel, all of the search query will be shown from Search Terms sectino.
Click on Marketing -> SEO & Search -> Search Terms
You will get all the search result grid for your site.

Error during compilation, Incompatible argument type: Required type: \Magento\Framework\DB\Adapter\AdapterInterface.

We can be resolved Compile time error by below way, The error looks like when running compilation command,

Incompatible argument type: Required type: \Magento\Framework\DB\Adapter\AdapterInterface. Actual type: string; File:
app/code/Rbj/CustomForm/Model/ResourceModel/Customform/Grid/Collection.php
[Magento\Framework\Validator\Exception]
Error during compilation

Solutions:

From Magento 2.2.* version we need to pass full class name in__construct()  instead of $connection = null as di argument in Collection.php file.

Replace, $connection = null argument with \Magento\Framework\DB\Adapter\AdapterInterface $connection = null  in __construct() parameter.

Run again command,
php bin/magento setup:di:compile
an error will be gone.

How to get Value from Store Configuration by Scope in Magento 2?

To Fetch the System Store Configuration Values by Scope level, Store or Website, You need to use ScopeConfigInterface with getValue() method.

We can get the Core config data table value programmatically using the given way,

public function __construct(
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Store\Model\StoreManagerInterface $storeManager
) {
    $this->scopeConfig = $scopeConfig;
    $this->storeManager = $storeManager;
}

Now call in a function,

public function getConfigValue() {
    return $this->scopeConfig->getValue("sectionId/groupId/fieldId",
                \Magento\Store\Model\ScopeInterface::SCOPE_STORE,$this->storeManager->getStore()->getStoreId();
}

First Argument sectionId/groupId/fieldId is from your etc/adminhtml/system.xml file.

The second Argument will be the Scope Value.

Third Argument will be scopeCode. It may be int, string or null value.

Demo system.xml to illustrate the example,

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="test" translate="label" type="text" sortOrder="310" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Test Settings</label>
            <group id="origin" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
                <label>Main label</label>
                <field id="postcode" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Postal Code</label>
                </field>
            </group>
        </section>
    </system>
</config>

In our case test/origin/postcode is the key value for sectionId/groupId/fieldId.