<?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="search" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Search ultimate</label>
            <tab>mirasvit</tab>
            <resource>Mirasvit_Search::search_config</resource>

            <group id="engine" translate="label" type="text" sortOrder="10" showInDefault="1">
                <label>Search engine configuration</label>
                <fieldset_css>mst_search_group_config</fieldset_css>
                <comment><![CDATA[Configure the search engine type, check its status, and manage index data.]]></comment>

                <field id="engine" translate="label" type="select" sortOrder="19" showInDefault="1">
                    <label>Search engine type</label>
                    <comment><![CDATA[Select the search engine for indexing and querying.]]></comment>
                    <config_path>catalog/search/engine</config_path>
                    <source_model>Magento\Search\Model\Adminhtml\System\Config\Source\Engine</source_model>
                </field>
            </group>

            <group id="advanced" translate="label comment tooltip" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Query handling and processing</label>
                <comment><![CDATA[Manage how search queries are interpreted and processed to enhance search accuracy and user experience. It includes settings for wildcard searches, automatic keyword replacements, and search logic configurations.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <group id="adjustments" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Wildcard and query adjustments</label>
                    <comment><![CDATA[Fine-tune how partial words, special characters, and keyword modifications affect search results.]]></comment>
                    <fieldset_css>mst_config_expanded</fieldset_css>

                    <field id="wildcard" translate="label" type="select" sortOrder="10" showInDefault="1">
                        <label>Wildcard search</label>
                        <comment><![CDATA[Allows customers to find products by part of a word.
                        Using an asterisk (*) as a placeholder helps return more relevant results.]]></comment>
                        <config_path>search/advanced/wildcard</config_path>
                        <source_model>Mirasvit\Search\Model\Config\Source\Wildcard</source_model>
                    </field>

                    <field id="wildcard_exceptions" translate="label comment tooltip" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0">
                        <label>Wildcard Exceptions</label>
                        <config_path>search/advanced/wildcard_exceptions</config_path>
                        <frontend_model>Mirasvit\Search\Block\Adminhtml\Config\Form\Field\WildcardExceptions</frontend_model>
                        <backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
                        <comment><![CDATA[List of keywords where wildcard search doesn’t apply.]]></comment>
                    </field>

                    <field id="replace_words" translate="label comment tooltip" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0">
                        <label>Automatic keyword replacement</label>
                        <comment><![CDATA[Define a list of words to be automatically replaced in search queries. Multiple keywords can be added in the "Find Word" column, separated by commas.]]></comment>
                        <config_path>search/advanced/replace_words</config_path>
                        <frontend_model>Mirasvit\Search\Block\Adminhtml\Config\Form\Field\ReplaceWords</frontend_model>
                        <backend_model>Magento\Config\Model\Config\Backend\Serialized\ArraySerialized</backend_model>
                    </field>

                    <field id="long_tail_expressions" translate="label comment tooltip" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0">
                        <label>Long-tail search expressions</label>
                        <config_path>search/advanced/long_tail_expressions</config_path>
                        <frontend_model>Mirasvit\Search\Block\Adminhtml\Config\Form\Field\LongTailExpressions</frontend_model>
                        <backend_model>Mirasvit\Search\Model\Config\Form\Field\LongTailExpressions</backend_model>
                        <comment><![CDATA[Optimizes searches with dashes or special characters (requires reindexing). <a href="https://mirasvit.com/blog/how-to-enhance-the-search-by-sku-in-magento-2-with-long-tail-search.html" target="_blank">Learn more</a>]]></comment>
                    </field>
                </group>

                <group id="logic" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Search logic</label>
                    <comment><![CDATA[Control how search queries are matched against indexed data to refine search precision and relevance.]]></comment>
                    <fieldset_css>mst_config_expanded</fieldset_css>

                    <field id="match_mode" translate="label comment tooltip" type="select" sortOrder="120" showInDefault="1">
                        <label>Search query match mode</label>
                        <comment><![CDATA[Defines whether the search is based on a partial query or a full match.]]></comment>
                        <tooltip><![CDATA[Set <b>AND</b> to show results where all requested keywords are found in the respective attributes. Set <b>OR</b> to show results when at least one of the requested keywords is found.]]></tooltip>
                        <config_path>search/advanced/match_mode</config_path>
                        <source_model>Mirasvit\Search\Model\Config\Source\MatchMode</source_model>
                    </field>
                </group>
            </group>

            <group id="feature" translate="label" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Search results and display</label>
                <comment><![CDATA[Define how search results are presented and refined to improve user experience and navigation.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <group id="visibility" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Search refinements and visibility</label>
                    <comment><![CDATA[Customize how search results appear.]]></comment>
                    <fieldset_css>mst_config_expanded</fieldset_css>

                    <field id="terms_highlighting" translate="label comment" type="select" sortOrder="50" showInDefault="1">
                        <label>Highlight keywords in results</label>
                        <comment><![CDATA[Highlights matched keywords for better visibility.]]></comment>
                        <config_path>search/feature/terms_highlighting</config_path>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    </field>

                    <field id="search_in" translate="label comment" type="select" sortOrder="10" showInDefault="1">
                        <label>Show "Search in" filter</label>
                        <comment><![CDATA[Enables filtering search results by category.]]></comment>
                        <config_path>search/feature/search_in</config_path>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    </field>

                    <field id="tabs_threshold" translate="label comment" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Display search indexes as tabs (result threshold)</label>
                        <comment><![CDATA[Displays search results as tabs based on content type (e.g., products, CMS pages) when results exceed a defined threshold. To always display results in tabs, enter 0 or leave the field empty. ]]></comment>
                        <tooltip><![CDATA[For example, set <b>5</b> to show results in tabs only when results qty is more than 5.]]></tooltip>
                        <config_path>search/feature/tabs_threshold</config_path>
                    </field>
                </group>

                <group id="search_category" translate="label comment" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Category page search</label>
                    <comment><![CDATA[Manage search functionality on category pages.]]></comment>
                    <fieldset_css>mst_config_expanded</fieldset_css>

                    <field id="category_search" translate="label comment" type="select" sortOrder="15" showInDefault="1">
                        <label>Show search bar on category pages</label>
                        <comment><![CDATA[Adds a search bar to category pages.]]></comment>
                        <config_path>search/feature/category_search</config_path>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    </field>

                    <field id="min_products_qty_to_display" translate="label comment" type="text" sortOrder="16" showInDefault="1">
                        <label>Minimum products for category search bar</label>
                        <config_path>search/feature/min_products_qty_to_display</config_path>
                        <depends>
                            <field id="category_search">1</field>
                        </depends>
                        <comment><![CDATA[Defines the minimum product count required to display the search bar.]]></comment>
                    </field>
                </group>
            </group>

            <group id="navigation" translate="label comment" type="text" sortOrder="35" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Navigation and redirection</label>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <group id="redirection_rules" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Redirection rules</label>
                    <comment><![CDATA[Define automatic redirection behaviors.]]></comment>
                    <fieldset_css>mst_config_expanded</fieldset_css>

                    <field id="noroute_to_search" translate="label comment" type="select" sortOrder="20" showInDefault="1">
                        <label>Redirect 404 pages to search results</label>
                        <comment><![CDATA[Redirects users from 404 pages to relevant search results.]]></comment>
                        <config_path>search/feature/noroute_to_search</config_path>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    </field>

                    <field id="redirect_on_single_result" translate="label comment" type="select" sortOrder="30" showInDefault="1">
                        <label>Auto-redirect for single result</label>
                        <comment><![CDATA[Automatically navigates to a product if it’s the only match.]]></comment>
                        <config_path>search/feature/redirect_on_single_result</config_path>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    </field>
                </group>

                <group id="seo" translate="label comment" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>SEO and external search</label>
                    <comment><![CDATA[Optimize search visibility for external engines.]]></comment>
                    <fieldset_css>mst_config_expanded</fieldset_css>

                    <field id="google_sitelinks" translate="label comment" type="select" sortOrder="40" showInDefault="1">
                        <label>Enable Google sitelinks search</label>
                        <config_path>search/feature/google_sitelinks</config_path>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                        <comment><![CDATA[Adds a Sitelink Search Box to the Google search results page.]]></comment>
                    </field>
                </group>
            </group>

            <group id="multi_store_mode" translate="label comment" type="text" sortOrder="45" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Multi-store and cross-store search</label>
                <comment><![CDATA[Manage search functionality across multiple store views, allowing customers to find relevant results across different stores.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <field id="enabled" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enable cross-store search</label>
                    <comment><![CDATA[Displays results in tabs for each store view. <i>Note:</i> Works only on the search results page. Autocomplete remains store-specific.]]></comment>
                    <config_path>search/multi_store_mode/enabled</config_path>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="stores" translate="label" type="multiselect" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Stores</label>
                    <config_path>search/multi_store_mode/stores</config_path>
                    <source_model>Magento\Config\Model\Config\Source\Store</source_model>
                    <depends>
                        <field id="enabled">1</field>
                    </depends>
                </field>
            </group>

            <group id="indexing" translate="label comment" type="text" sortOrder="55" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Content indexing and search optimization</label>
                <comment><![CDATA[Configure content indexing settings to enhance search accuracy and performance.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <field id="content_widget_indexation" translate="label comment" type="select" sortOrder="90" showInDefault="1">
                    <label>Index CMS widgets</label>
                    <comment><![CDATA[Includes Magento CMS widgets in search results.]]></comment>
                    <config_path>search/feature/content_widget_indexation</config_path>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="allow_ascii_folding" translate="label comment" type="select" sortOrder="100" showInDefault="1">
                    <label>Normalize accented characters</label>
                    <comment><![CDATA[Converts accented characters to plain text for Elasticsearch.]]></comment>
                    <config_path>search/feature/allow_ascii_folding</config_path>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
                <field id="popularity_relevance_period" translate="label comment" type="text" sortOrder="110" showInDefault="1">
                    <label>Calculate products popularity for last N months</label>
                    <comment><![CDATA[Defines the period per which the product popularity will be considered in sorting. For all the sales time period, please set 0 or leave empty]]></comment>
                    <config_path>search/feature/popularity_relevance_period</config_path>
                </field>
            </group>

            <group id="tracking" translate="label" type="text" sortOrder="65" showInDefault="1" showInWebsite="0" showInStore="0">
                <label>Search tracking and analytics</label>
                <comment><![CDATA[Manage search data collection and tracking to refine search performance and user insights.]]></comment>
                <fieldset_css>mst_search_group_config</fieldset_css>

                <field id="ignored_ips" translate="label comment tooltip" type="text" sortOrder="80" showInDefault="1" showInWebsite="0" showInStore="0">
                    <label>Ignored IPs for tracking</label>
                    <config_path>search/feature/ignored_ips</config_path>
                    <comment><![CDATA[Excludes specified IPs from search analytics.]]></comment>
                    <tooltip><![CDATA[Set <b>213.180.203.242,114.119.135.84</b> to exclude a few specified IPs from analytics]]></tooltip>
                </field>
            </group>
        </section>
    </system>
</config>
