<!--
/**
 * Smile_ElasticsuiteThesaurus module configuration
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
 * versions in the future.
 *
 * @category  Smile
 * @package   Smile\ElasticsuiteThesaurus
 * @author    Richard BAYET <richard.bayet@smile.fr>
 * @copyright 2024 Smile
 * @license   Open Software License ("OSL") v. 3.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="smile_elasticsuite_thesaurus_settings" translate="label" type="text" sortOrder="1000" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Thesaurus (global settings)</label>
            <tab>smile_elasticsuite</tab>
            <resource>Smile_ElasticsuiteThesaurus::manage</resource>

            <group id="cache" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Cache settings</label>
                <field id="always" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Always cache thesaurus application results</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment><![CDATA[Set this to "No" to conditionally cache the results of user search query rewriting by active thesaurus rules. This can be used in peak trafic times to reduce the impact on your cache component with a trade-off of an increased volume of analysis requests sent to Elasticsearch/Opensearch and increased CPU usage.]]></comment>
                </field>
                <field id="min_rewrites" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Minimum amount of alternative queries</label>
                    <validate>integer validate-zero-or-greater</validate>
                    <depends>
                        <field id="always">0</field>
                    </depends>
                    <comment><![CDATA[The minimum amount of alternative queries that must be generated for a given original user search for enabling the storage of the results in the cache component. Set this to 1, for instance, to only cache the results when there is at least one alternative query generated by the thesaurus rules. Defaults to 0: cache storage is used even when there is no alternative queries through the thesaurus.]]></comment>
                </field>
                <field id="ttl" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Cache TTL</label>
                    <validate>required-entry integer validate-digits validate-digits-range digits-range-300-2592000</validate>
                    <comment><![CDATA[Cache lifetime in seconds, between 300 (5 minutes) and 2592000 (30 days). Defaults to 7200 (2 hours).]]></comment>
                </field>
            </group>

            <group id="analysis" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Text Analysis</label>
                <field id="use_stemming" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
                    <label>Enable stemming on synonym and expansion rules</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    <comment><![CDATA[If enabled, by applying the same stemming behavior that occurs when indexing product data, this will allow search queries to match synonym and expansion rules more broadly with regard to singular and plural forms of words. For instance, for a synonym rule "story,tale", searching either for "story" <strong>or "stories"</strong> will trigger the synonym and make Elasticsuite also search for "tale". For an expansion rule "sport => football,tennis,soccer,running", searching either for "sport" <strong>or "sports"</strong> will trigger the expansion and make Elasticsuite also search for "football", "tennis", "soccer" and "running".<br />If disabled, the legacy stricter matching mode will be applied, where searching for "stor<strong>ies</strong>" would <strong>not</strong> trigger a "story,tale" synonym or searching for "sport<strong>s</strong>" would not trigger a "sport => football,tennis,soccer,running" expansion.]]></comment>
                </field>
            </group>
        </section>
    </system>
</config>
