# Schema for the configuration files of the search module.

search.settings:
  type: config_object
  label: 'Search settings'
  constraints:
    FullyValidatable: ~
  mapping:
    and_or_limit:
      type: integer
      label: 'AND/OR combination limit'
      constraints:
        PositiveOrZero: ~
    default_page:
      type: string
      label: 'Default search page'
      constraints:
        ConfigExists:
          prefix: search.page.
      # @see \Drupal\search\SearchPageRepository::getDefaultSearchPage()
      # @see \Drupal\search\SearchPageRepository::clearDefaultSearchPage()
      requiredKey: false
    index:
      type: mapping
      label: 'Indexing settings'
      mapping:
        cron_limit:
          type: integer
          label: 'Number of items to index per cron run'
          constraints:
            Range:
              min: 1
        overlap_cjk:
          type: boolean
          label: 'Simple CJK handling'
        minimum_word_size:
          type: integer
          label: 'Minimum word length to index'
          constraints:
            Range:
              min: 1
        tag_weights:
          type: mapping
          label: 'HTML tags weight'
          mapping:
            h1:
              type: weight
              label: 'Tag h1 weight'
            h2:
              type: weight
              label: 'Tag h2 weight'
            h3:
              type: weight
              label: 'Tag h3 weight'
            h4:
              type: weight
              label: 'Tag h4 weight'
            h5:
              type: weight
              label: 'Tag h5 weight'
            h6:
              type: weight
              label: 'Tag h6 weight'
            u:
              type: weight
              label: 'Tag u weight'
            b:
              type: weight
              label: 'Tag b weight'
            i:
              type: weight
              label: 'Tag i weight'
            strong:
              type: weight
              label: 'Tag strong weight'
            em:
              type: weight
              label: 'Tag em weight'
            a:
              type: weight
              label: 'Tag a weight'
    logging:
      type: boolean
      label: 'Log searches'

search.page.*:
  type: config_entity
  label: 'Search page'
  constraints:
    FullyValidatable: ~
  mapping:
    id:
      type: machine_name
      label: 'ID'
    label:
      type: required_label
      label: 'Label'
    path:
      type: path
      label: 'Search page path'
      constraints:
        NotBlank: []
    weight:
      type: weight
      label: 'Weight'
    plugin:
      type: string
      label: 'Plugin'
      constraints:
        PluginExists:
          manager: plugin.manager.search
          interface: 'Drupal\search\Plugin\SearchInterface'
    configuration:
      type: search.plugin.[%parent.plugin]

block.settings.search_form_block:
  type: block_settings
  label: 'Search block'
  constraints:
    FullyValidatable: ~
  mapping:
    page_id:
      type: string
      label: 'Search page'
      # Optional: falls back to the default search page.
      # @see \Drupal\search\Form\SearchBlockForm::buildForm()
      # @see \Drupal\search\SearchPageRepositoryInterface::getDefaultSearchPage()
      nullable: true
      constraints:
        ConfigExists:
          prefix: search.page.
