<commit_before>require 'active_support/concern'

module Georgia
  module Indexer
    module SolrAdapter
      module GeorgiaPostExtension
        extend ActiveSupport::Concern

        included do
          searchable do
            text :title, stored: true do
              revisions.map{|r| r.contents.map(&:title)}.flatten.uniq.join(', ')
            end
            text :excerpt, stored: true do
              revisions.map{|r| r.contents.map(&:excerpt)}.flatten.uniq.join(', ')
            end
            text :text do
              revisions.map{|r| r.contents.map(&:text)}.flatten.uniq.join(', ')
            end
            text :keywords do
              revisions.map{|r| r.contents.map(&:keyword_list)}.flatten.uniq.join(', ')
            end
            text :tags do
              tag_list.join(', ')
            end
            text :url
            text :template
            string :title
            string :excerpt
            string :text
            string :url
            string :template
            string :state do
              public? ? 'public' : 'private'
            end
            string :class_name do
              self.class.name
            end
            string :keywords, stored: true, multiple: true do
              revisions.map{|r| r.contents.map(&:keyword_list)}.flatten.uniq
            end
            string :tag_list, stored: true, multiple: true # Array for facets
            string :tags, stored: true do # Single list for ordering
              tag_list.join(', ')
            end
            string :month, stored: true
            string :year, stored: true
            time :published_at
            time :updated_at # default order
          end

          def self.search_index model, params
            model.search do
              fulltext params[:query] do
                fields(:title, :excerpt, :text, :keywords, :tags, :url, :template)
              end
              facet :state, :template, :tag_list, :month, :tags
              with(:class_name, model.to_s)
              with(:state, params[:s]) unless params[:s].blank?
              with(:template, params[:t]) unless params[:t].blank?
              with(:tag_list).all_of(params[:tg]) unless params[:tg].blank?
              order_by (params[:o] || :updated_at), (params[:dir] || :desc)
              paginate(page: params[:page], per_page: (params[:per] || 25))
              with(:month, params[:m]) unless params[:m].blank?
              with(:tags, params[:c]) unless params[:t].blank?
            end
          end

        end
      end
    end
  end
end<commit_msg>Boost title field in fulltext searches<commit_after>require 'active_support/concern'

module Georgia
  module Indexer
    module SolrAdapter
      module GeorgiaPostExtension
        extend ActiveSupport::Concern

        included do
          searchable do
            text :title, stored: true do
              revisions.map{|r| r.contents.map(&:title)}.flatten.uniq.join(', ')
            end
            text :excerpt, stored: true do
              revisions.map{|r| r.contents.map(&:excerpt)}.flatten.uniq.join(', ')
            end
            text :text do
              revisions.map{|r| r.contents.map(&:text)}.flatten.uniq.join(', ')
            end
            text :keywords do
              revisions.map{|r| r.contents.map(&:keyword_list)}.flatten.uniq.join(', ')
            end
            text :tags do
              tag_list.join(', ')
            end
            text :url
            text :template
            string :title
            string :excerpt
            string :text
            string :url
            string :template
            string :state do
              public? ? 'public' : 'private'
            end
            string :class_name do
              self.class.name
            end
            string :keywords, stored: true, multiple: true do
              revisions.map{|r| r.contents.map(&:keyword_list)}.flatten.uniq
            end
            string :tag_list, stored: true, multiple: true # Array for facets
            string :tags, stored: true do # Single list for ordering
              tag_list.join(', ')
            end
            string :month, stored: true
            string :year, stored: true
            time :published_at
            time :updated_at # default order
          end

          def self.search_index model, params
            model.search do
              fulltext params[:query] do
                fields(:title, :excerpt, :text, :keywords, :tags, :url, :template)
                boost_fields title: 5.0
              end
              facet :state, :template, :tag_list, :month, :tags
              with(:class_name, model.to_s)
              with(:state, params[:s]) unless params[:s].blank?
              with(:template, params[:t]) unless params[:t].blank?
              with(:tag_list).all_of(params[:tg]) unless params[:tg].blank?
              order_by (params[:o] || :updated_at), (params[:dir] || :desc)
              paginate(page: params[:page], per_page: (params[:per] || 25))
              with(:month, params[:m]) unless params[:m].blank?
              with(:tags, params[:c]) unless params[:t].blank?
            end
          end

        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11024520053221822, 'fraction_numerical': 0.0011404675917126021, 'mean_word_length': 1.5743639921722115, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6886957', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1393, 'n_words': 369}