<commit_before>class SearchController < ApplicationController
  include Concerns::Searchable
  after_action :enable_caching

  before_action :ignore_empty_query, only: [ :search_results]
  before_action :load_search, only: [:search_results]

  def index
    categories = I18n.t('search.categories')
    cms_root_pages = Comfy::Cms::Page.root.children
    @categories = []

    categories.map do |category|
      cms_page = cms_root_pages.find_by(slug: category)
      if cms_page
        @categories << { id: cms_page.id.to_s, title: cms_page.label}
      else
        @categories << { id: category, title: category.capitalize }
      end
    end

    @query = search_params[:search_term]
  end

  def search_results
    _options = {
      page: search_params[:requested_page],
      per_page: search_params[:items_per_page]
    }
    @results = Search::FullSerializer.new(@search, _options).serialize

    render json: @results
  end

  def map
    render :index
  end

  def autocomplete
    db_type = search_params[:type]
    @results = Autocompletion.lookup(search_params[:search_term], db_type, search_index(db_type))

    render json: @results
  end

  private

  def search_index db_type
    case db_type
      when 'country'
        Search::COUNTRY_INDEX
      when 'region'
        Search::REGION_INDEX
      else
        Search::PA_INDEX
    end
  end

  def search_params
    params.permit(:search_term, :type, :requested_page, :items_per_page, :search_index, :filters)
  end
end<commit_msg>Fix brfull search erroring due to method name clash<commit_after>class SearchController < ApplicationController
  include Concerns::Searchable
  after_action :enable_caching

  before_action :ignore_empty_query, only: [ :search_results]
  before_action :load_search, only: [:search_results]

  def index
    categories = I18n.t('search.categories')
    cms_root_pages = Comfy::Cms::Page.root.children
    @categories = []

    categories.map do |category|
      cms_page = cms_root_pages.find_by(slug: category)
      if cms_page
        @categories << { id: cms_page.id.to_s, title: cms_page.label}
      else
        @categories << { id: category, title: category.capitalize }
      end
    end

    @query = search_params[:search_term]
  end

  def search_results
    _options = {
      page: search_params[:requested_page],
      per_page: search_params[:items_per_page]
    }
    @results = Search::FullSerializer.new(@search, _options).serialize

    render json: @results
  end

  def map
    render :index
  end

  def autocomplete
    db_type = search_params[:type]
    @results = Autocompletion.lookup(search_params[:search_term], db_type, autocomplete_search_index(db_type))

    render json: @results
  end

  private

  def autocomplete_search_index db_type
    case db_type
      when 'country'
        Search::COUNTRY_INDEX
      when 'region'
        Search::REGION_INDEX
      else
        Search::PA_INDEX
    end
  end

  def search_params
    params.permit(:search_term, :type, :requested_page, :items_per_page, :search_index, :filters)
  end
end
{'fraction_non_alphanumeric': 0.08930899608865711, 'fraction_numerical': 0.001303780964797914, 'mean_word_length': 3.4158273381294966, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3729390', 'n_tokens_mistral': 986, 'n_tokens_neox': 962, 'n_words': 213}